Re: Understanding Aliases - Mailing list pgsql-general

From Tom Lane
Subject Re: Understanding Aliases
Date
Msg-id 14378.1197386869@sss.pgh.pa.us
Whole thread Raw
In response to Re: Understanding Aliases  ("Stanislav Raskin" <sr@brainswell.de>)
Responses Re: Understanding Aliases
List pgsql-general
"Stanislav Raskin" <sr@brainswell.de> writes:
> Still no Idea why it does not work with the alias.

SELECT-list output aliases name the *output* columns of the SELECT.
Those output columns are not available to the SELECT's computation
clauses.  Otherwise you'd have a logical circularity --- by definition,
the output row(s) can't have been computed yet when you're evaluating
a WHERE condition.

People frequently think that because ORDER BY can refer to the
output-column aliases, other clauses should be able to do it too,
but this is not so.  Conceptually, ORDER BY happens after computation
of the output rows, so there's no logical inconsistency in allowing
it to do that ... but it's certainly confused enough people that
one wonders whether the SQL committee shouldn't have left that wart
out of the language.

            regards, tom lane

pgsql-general by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: Hijack!
Next
From: "Mason Hale"
Date:
Subject: Re: partitioned table query question