salah jubeh <s_ju...@yahoo.com> writes:
> On the row level,  the value of a and b are know, so why we need a temporary 
> table or CTE. Why I can not use it directly  as shown in the example below. 
> why a and b can not be used as aliases for the column names ? I want to know 
> the theoretical reason behind it?

The SQL standard envisions all the expressions in a SELECT list being
computed concurrently and independently.  So they can't refer to each
other.  If they could, it would introduce ambiguity.  Consider a table
t that provides columns x,y,z, and suppose we have

        SELECT x AS z, y, y+z AS sum FROM t;

If cross-references were allowed, it would be unclear what the last "z"
is supposed to refer to.

                        regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to