The following bug has been logged online:
Bug reference: 1265
Logged by: Ansis
Email address: ataols(at)latnet(dot)lv
PostgreSQL version: 7.4.2
Operating system: Gentoo Linux
Description: sorting by (ORDER BY) result of an operation for names
assigned by AS does not work
Details:
The query:
SELECT id, lang as name, (SELECT lang FROM participants WHERE id =
event.participant) as pname FROM event ORDER BY name || pname;
returns an error:
ERROR: column "name" does not exist
However, "ORDER BY name" works, "ORDER BY name, pname" works etc. Also, if
I use original column names, not assigned ones, it works with cncatenation
operator too. So, the error occurs only then assigned names are used inside
operator - the Postgre does not find this name.
It looks like a bug - and an easy fixable one.