Giorgio Volpe writes:
> May be it's my ignorance about sql ...
> but why cannot i use alias name of a column in a where clause?
>
> # select key as cc from mytable where cc > 0;
> ERROR: Attribute 'cc' not found
The processing order of this command is, perhaps unintuitively, FROM ->
WHERE -> SELECT [-> ORDER BY]. The aliases introduced in the SELECT list
are not available in the WHERE expression (but they would be in the ORDER
BY list). If you want to use an alias in the WHERE clause you have to
introduce it in the FROM clause, such as:
SELECT * FROM mytable AS myalias (xx, yy, zz) WHERE zz > 0;
This may or may not be actually useful in your case.
--
Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter