Hello,
on the occasion of a subselect I found a behavior in PostgreSQL 7.1 that I
consider faulty, but would like to hear comments before complaining to the
hackers:
It seems that pgsql can not use a named result column in a function for
ORDER BY. The same named result column can be used in an ORDER BY clause a)
directly, _without_ the function or b) _with_ the same function but with
the _original_ column name.
Here is the example - this fails with "ERROR: Attribute 'max_date' not found":
SELECT content, datetime AS max_date FROM cftext ORDER by date_part('hour', max_date)
Whereas this works both:
a) SELECT content, datetime AS max_date FROM cftext ORDER by max_date
b) SELECT content, datetime AS max_date FROM cftext ORDER by date_part('hour', datetime)
Now in this example the alternative works fine, but if you use a Sub-SELECT
there is no alternative to a named result column. I posted the simple
example here to focus on the issue.
- Thanks for any hints -
// Bernd vdB