From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | salah jubeh <s_jubeh(at)yahoo(dot)com> |
Cc: | Simon Tokumine <simon(at)vizzuality(dot)com>, pgsql <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: can not use the column after rename |
Date: | 2011-12-21 16:06:24 |
Message-ID: | 5866.1324483584@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
salah jubeh <s_jubeh(at)yahoo(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2011-12-21 16:13:51 | Re: out of memory error with loading pg_dumpall |
Previous Message | Dara Olson | 2011-12-21 14:50:29 | Re: out of memory error with loading pg_dumpall |