pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bryce Nesbitt <bryce1@obviously.com>
To: pgsql-sql@postgresql.org
Subject: Re: Can function results be used in WHERE?
Date: Mon, 10 Jul 2006 17:24:28 -0700
Message-ID: <44B2EFBC.1090201@obviously.com> (raw)
In-Reply-To: <bf05e51c0607101533ld2ee15fm4cff4f7ce23a320a@mail.gmail.com>
References: <44B29376.2030107@obviously.com>
	<bf05e51c0607101302w271c7773tdec47e76b192f2c9@mail.gmail.com>
	<44B2CFC7.7060101@obviously.com>
	<bf05e51c0607101533ld2ee15fm4cff4f7ce23a320a@mail.gmail.com>

Aaron Bono wrote:
>
>
> On 7/10/06, *Bryce Nesbitt* <bryce1@obviously.com
> <mailto:bryce1@obviously.com>> wrote:
>
>
>     I think it is ugly also, but no other syntax seems to work:
>
>     stage=# select
>     pod_code,lat,lon,calculate_distance(lat,lon,37.789629,-122.422082) as
>     dist from eg_pod where dist < 1 order by dist desc limit 10;
>     ERROR:  column "dist" does not exist
>
>
> SELECT
>    pod_code,
>    lat,
>    lon,
>    calculate_distance(lat,lon,37.789629,-122.422082) as dist
> FROM eg_pod
> WHERE calculate_distance(lat,lon, 37.789629,-122.422082) < 1
> ORDER BY calculate_distance(lat,lon,37.789629,-122.422082) desc limit 10;
Yep, that works.  I guess with IMMUTABLE it's even effecient.
But I have to pass 6 arguments, not 2.  Is there a way to make it look
cleaner?
I had expected using the column label (e.g. "dist") to work with WHERE,
just as it does with ORDER BY.

                               -Bryce


-- 
----
Visit http://www.obviously.com/




view thread (10+ messages)  latest in thread

Message-ID: <44B2EFBC.1090201@obviously.com>
Permalink:  ../44B2EFBC.1090201@obviously.com/
Also on:    postgresql.org/message-id/44B2EFBC.1090201@obviously.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bryce1@obviously.com
  Subject: Re: Can function results be used in WHERE?
  In-Reply-To: <44B2EFBC.1090201@obviously.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox