Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 0A3554765B1 for ; Wed, 19 Jun 2002 18:19:19 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 494B0475F7B for ; Wed, 19 Jun 2002 18:11:38 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id E8B5AD606; Wed, 19 Jun 2002 15:11:38 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id DC5E95C02; Wed, 19 Jun 2002 15:11:38 -0700 (PDT) Date: Wed, 19 Jun 2002 15:11:38 -0700 (PDT) From: Stephan Szabo To: Michael Agbaglo Cc: Subject: Re: syntax for access an alias in the where clause ? In-Reply-To: <3D10C770.7040100@shifted-bytes.de> Message-ID: <20020619150938.U78365-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200206/262 X-Sequence-Number: 8227 On Wed, 19 Jun 2002, 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 ? At least in postgres, no, because the where clause is processed before the select list so the alias doesn't have meaning. I believe the SQL spec says no as well.