Search Postgresql Archives

Re: inconsistency in aliasing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



	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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux