Re: [SQL] Getting the output of a function used in a where clause

2005-04-22 Thread Bill Lawrence
, Thanks for all the great advice! -Original Message- From: Tom Lane [mailto:[EMAIL PROTECTED] Sent: Monday, April 18, 2005 8:00 PM To: Rod Taylor Cc: Bill Lawrence; Scott Marlowe; PFC; pgsql-sql@postgresql.org Subject: Re: [SQL] Getting the output of a function used in a where clause

Re: [SQL] Getting the output of a function used in a where clause

2005-04-19 Thread PFC
Thanks Tom and Rod. There are indeed several additional conditions on the "real" query which prune the search space (I formulate a quick search box and filter on Lat/Lon's within the box). Since my user interface limits the search to a 30 mile radius, there are at most 81 results (in New York ci

Re: [SQL] Getting the output of a function used in a where clause

2005-04-18 Thread Tom Lane
Rod Taylor <[EMAIL PROTECTED]> writes: > You can force it with a subselect though: > SELECT * FROM (SELECT zipcode, zipdist($lat1d,$lon1d,lat,long) > as distance > from zipcodes) AS tab where distance <= $dist; The above will *not* stop zipdist from being run twice

Re: [SQL] Getting the output of a function used in a where clause

2005-04-18 Thread Bill Lawrence
Marlowe [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 12, 2005 6:55 AM To: Bill Lawrence Cc: PFC; pgsql-sql@postgresql.org Subject: Re: [SQL] Getting the output of a function used in a where clause Why not just do: SELECT zipcode, zipdist($lat1d,$lon1d,lat,long) as distance from zipcodes where

Re: [SQL] Getting the output of a function used in a where clause

2005-04-18 Thread Rod Taylor
<= $dist; > Bill > > > > -Original Message- > From: Scott Marlowe [mailto:[EMAIL PROTECTED] > Sent: Tuesday, April 12, 2005 6:55 AM > To: Bill Lawrence > Cc: PFC; pgsql-sql@postgresql.org > Subject: Re: [SQL] Getting the output of a function used in a where clause >

Re: [SQL] Getting the output of a function used in a where clause

2005-04-12 Thread Bill Lawrence
t: Re: [SQL] Getting the output of a function used in a where clause > Boy I sure thought that would work... I received the following from > postgres: > > ERROR: Attribute "distance" not found. > > Started looking into gist Looks complex. > > Any other ideas?

Re: [SQL] Getting the output of a function used in a where clause

2005-04-12 Thread Scott Marlowe
ERROR: Attribute "distance" not found. > > Started looking into gist Looks complex. > > Any other ideas? > > > -Original Message- > From: PFC [mailto:[EMAIL PROTECTED] > Sent: Monday, April 11, 2005 1:51 AM > To: Bill Lawrence; pgsql-sql@po

Re: [SQL] Getting the output of a function used in a where clause

2005-04-11 Thread Bill Lawrence
M To: Bill Lawrence; pgsql-sql@postgresql.org Subject: Re: [SQL] Getting the output of a function used in a where clause try: SELECT zipcode, zipdist($lat1d,$lon1d,lat,long) as distance from zipcodes where distance <= $dist;"; OR you could use a gist index with a geometric datatype to ge

Re: [SQL] Getting the output of a function used in a where clause

2005-04-11 Thread PFC
try: SELECT zipcode, zipdist($lat1d,$lon1d,lat,long) as distance from zipcodes where distance <= $dist;â; OR you could use a gist index with a geometric datatype to get it a lot faster. On Sat, 09 Apr 2005 03:43:39 +0200, Bill Lawrence <[EMAIL PROTECTED]> wrote: HI, Iâm a newbie so please

[SQL] Getting the output of a function used in a where clause

2005-04-10 Thread Bill Lawrence
HI,   I’m a newbie so please bear with me. I have a function defined (got it from one of your threads… thanks Joe Conway) which calculates the distance  between 2 zip code centeroids (in lat,long). This thing works great. However, I want to sort my results by distance without incurring th