Reg Me Please wrote:
> critik=# select current_timestamp::abstime::int4 as score order
by score +
> 1; ERROR: column "score" does not exist
> LINE 1: ...urrent_timestamp::abstime::int4 as score order by
score + 1 ...
>
> Any idea ?
>
> Thanks,
Looks and smells like a bug.
Read
http://www.postgresql.org/docs/8.3/static/queries-order.html
<quote>
The sort expression(s) can be any expression that would be valid in
the query's select list
</quote>
score+1 is not valid in the query's select list (as well as "score"
anyway)
<quote>
For backwards compatibility with the SQL92 version of the standard, a
sort_expression can instead be the name or number of an output column
</quote>
so that's why "score" alone works in the order by, despite it not being
valid in the select list.
<quote>
Note that an output column name has to stand alone, it's not allowed
as part of an expression
</quote>
Which looks like the very issue discussed here, and it just behaves as
documented.
Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage:
http://www.manitou-mail.org
--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general