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

From: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>
To: Michael Agbaglo <byteshifter(at)shifted-bytes(dot)de>
Cc: Wei Weng <wweng(at)kencast(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: syntax for access an alias in the where clause ?
Date: 2002-06-19 23:56:22
Message-ID: 20020619235622.GA3650@rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, Jun 19, 2002 at 11:13:31PM +0200, Michael Agbaglo wrote:
>
>
> Wei Weng wrote:
>
> >Is it allowed to use spaces in postgresql alias?
> >
> >Why dont you try to use alias1 instead of "alias 1"?
>
>
>
> really amusing... muhahaha...

I'm sure he didn't mean to make a joke, nor ridicule you, it was just a
misundertanding.

> I don't use the brackets either... I didn't assume that you might be
> interested in how the expression looks like or what aliases I'm using...

Sometimes, it makes all the difference. In this case, it doesn't. Aliases
are not available in the 'order by' clause: you need to repeat te full
expressions there.

Ross

>
>
> >
> >
> >On Wed, 2002-06-19 at 14:03, 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(at)postgresql(dot)org
> >>
> >>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Rudi Starcevic 2002-06-20 04:01:35 Rows affected
Previous Message Stephan Szabo 2002-06-19 22:11:38 Re: syntax for access an alias in the where clause ?