From: | Jean-Luc Lachance <jllachan(at)nsd(dot)ca> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Sort problem |
Date: | 2002-02-26 16:41:32 |
Message-ID: | 3C7BBABC.AFB24FF4@nsd.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
Tom,
You are right about the ORDER BY CLAUSE, but the parser should be able
to rewrite the query so that I do not have to retype the whole thing...
Tom Lane wrote:
>
> Jean-Luc Lachance <jllachan(at)nsd(dot)ca> writes:
> > Can someone (Tom maybe) please tell me why one can not use an alias from
> > the select list in the where clause or the order by clause.
>
> Eh? You can do it in the ORDER BY clause:
>
> regression=# select f1 as alias from int4_tbl order by alias;
> alias
> -------------
> -2147483647
> -2147483647
> -123456
> -123456
> 0
> 0
> 123456
> 123456
> 2147483647
> 2147483647
> (10 rows)
>
> As for WHERE, the reason you can't do it there is that it wouldn't be
> meaningful. The SELECT list is not calculated until *after* the WHERE
> conditions are applied. Any SQL book should tell you about the stages
> of processing of a SELECT query...
>
> regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | George Osvald | 2002-02-26 16:50:23 | postgres on user account |
Previous Message | Jean-Luc Lachance | 2002-02-26 16:37:07 | Re: help with getting index scan |
From | Date | Subject | |
---|---|---|---|
Next Message | Dan MacNeil | 2002-02-26 16:44:45 | Re: Removing duplicates |
Previous Message | Josh Berkus | 2002-02-26 16:39:26 | Re: Removing duplicates |