Re: can not use the column after rename - Mailing list pgsql-general

From Tom Lane
Subject Re: can not use the column after rename
Date
Msg-id 5866.1324483584@sss.pgh.pa.us
Whole thread Raw
In response to Re: can not use the column after rename  (salah jubeh <s_jubeh@yahoo.com>)
List pgsql-general
salah jubeh <s_jubeh@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
thetheoretical 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

pgsql-general by date:

Previous
From: "Dara Olson"
Date:
Subject: Re: out of memory error with loading pg_dumpall
Next
From: Tom Lane
Date:
Subject: Re: out of memory error with loading pg_dumpall