Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id BB83047604F for ; Wed, 19 Jun 2002 18:08:13 -0400 (EDT) Received: from web20810.mail.yahoo.com (web20810.mail.yahoo.com [216.136.226.199]) by postgresql.org (Postfix) with SMTP id EC837475C37 for ; Wed, 19 Jun 2002 18:04:26 -0400 (EDT) Message-ID: <20020619220427.58854.qmail@web20810.mail.yahoo.com> Received: from [208.13.35.95] by web20810.mail.yahoo.com via HTTP; Wed, 19 Jun 2002 15:04:27 PDT Date: Wed, 19 Jun 2002 15:04:27 -0700 (PDT) From: Jeff Eckermann Subject: Re: syntax for access an alias in the where clause ? To: Michael Agbaglo , pgsql-sql@postgresql.org In-Reply-To: <3D10C770.7040100@shifted-bytes.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200206/261 X-Sequence-Number: 8226 The WHERE clause is evaluated before the SELECT list, at which point the value of "[alias 1]" is not known. You will need to use "[expression 1]" there instead. ORDER BY is evaluated after the SELECT, so "[alias 1]" can be used there with no problems. --- Michael Agbaglo wrote: > Hi ! > > It's long ago since I used SQL :-) > > select [expression 1] as [alias 1], [expression 2] > as [alias 2] > where [alias 1] < [alias 2] > order by [alias 2] - [alias 1] > > ---> ERROR: Attribute '[alias 1]' not found > > I found a lot of 'select [expression] as' but I've > never seen somebody > accessing the alias ... Can't this be done ? > > M. > > > > > ---------------------------(end of > broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com