Re: syntax for access an alias in the where clause ?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Michael Agbaglo <byteshifter(at)shifted-bytes(dot)de>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: syntax for access an alias in the where clause ?
Date: 2002-06-19 22:11:38
Message-ID: 20020619150938.U78365-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ross J. Reedstrom 2002-06-19 23:56:22 Re: syntax for access an alias in the where clause ?
Previous Message Jeff Eckermann 2002-06-19 22:04:27 Re: syntax for access an alias in the where clause ?