"Robert J.C. Ivens" <robert@xxxxxxxxxxx> writes: > I am not sure if there ever was a feature request for using defined > column aliases in the rest of a query. Yes, we've heard that before. Many times. It's not going to happen, and here's why: it's flat out contrary to the SQL specification, as well as to the basic intuitive semantics of SQL. The SELECT list is supposed to be evaluated as the last step of a query (well, last except for ORDER BY, which is why there's an exception for that). It's nonsensical for WHERE etc to depend on the results of the SELECT list. As an example of why this is important, consider SELECT x/y AS z FROM tab WHERE y <> 0 If the WHERE clause doesn't act before the SELECT list is computed, the query is going to fail with divisions-by-zero, exactly what the WHERE clause is trying to prevent. So it'd be nonsensical to refer to z in the WHERE clause. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general