X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 6F63C9FB321 for ; Mon, 10 Jul 2006 19:34:03 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 87302-03 for ; Mon, 10 Jul 2006 19:33:59 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.191]) by postgresql.org (Postfix) with ESMTP id 689A79FB2FB for ; Mon, 10 Jul 2006 19:33:58 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id p77so123492nfc for ; Mon, 10 Jul 2006 15:33:57 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=UG1X/ZvIWYlWY2z6BqQl3GK0iZSwCbuA16eDsuMwhXVMFHoaWQNE6BRWr7IDtD5YVnZtGgrN+qkkwk/8ulJnpoNijgKRrwR7nb4qwngMme9QlY4ZIHjLt3J9Yb8q/u0TNZvtDsLvOO/OTQaBgJ0yx3uYZAFi7xrDOsl76weG1mE= Received: by 10.78.165.16 with SMTP id n16mr1904931hue; Mon, 10 Jul 2006 15:33:57 -0700 (PDT) Received: by 10.78.29.2 with HTTP; Mon, 10 Jul 2006 15:33:57 -0700 (PDT) Message-ID: Date: Mon, 10 Jul 2006 17:33:57 -0500 From: "Aaron Bono" To: "Bryce Nesbitt" Subject: Re: Can function results be used in WHERE? Cc: pgsql-sql@postgresql.org In-Reply-To: <44B2CFC7.7060101@obviously.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_41574_8957968.1152570837189" References: <44B29376.2030107@obviously.com> <44B2CFC7.7060101@obviously.com> X-Google-Sender-Auth: 9a8dd6365617730e X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/163 X-Sequence-Number: 25737 ------=_Part_41574_8957968.1152570837189 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/10/06, Bryce Nesbitt 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; ------=_Part_41574_8957968.1152570837189 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline

On 7/10/06, Bryce Nesbitt <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; 

------=_Part_41574_8957968.1152570837189--