SELECT DISTINCT ... ORDER BY UPPER(column_name) fails
SELECT DISTINCT ... ORDER BY UPPER(column_name) fails
От:
Aymeric Levaux <aymeric@javablackbelt.com>
Дата:
On pgsql 8.2, if you do the following query, everything is fine:
SELECT DISTINCT tag FROM logs ORDER BY tag;
But if you'd like to do a case insensitive order by like this:
SELECT DISTINCT tag FROM logs ORDER BY UPPER(tag);
or
SELECT DISTINCT tag FROM logs ORDER BY LOWER(tag);
You get the following error message :
for SELECT DISTINCT, ORDER BY expressions must appear in select list.
It is weird as the order by column appears in the select.
Any thoughts?
SELECT DISTINCT tag FROM logs ORDER BY tag;
But if you'd like to do a case insensitive order by like this:
SELECT DISTINCT tag FROM logs ORDER BY UPPER(tag);
or
SELECT DISTINCT tag FROM logs ORDER BY LOWER(tag);
You get the following error message :
for SELECT DISTINCT, ORDER BY expressions must appear in select list.
It is weird as the order by column appears in the select.
Any thoughts?
Re: SELECT DISTINCT ... ORDER BY UPPER(column_name) fails
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Aymeric Levaux writes: > SELECT DISTINCT tag FROM logs ORDER BY UPPER(tag); > You get the following error message : > for SELECT DISTINCT, ORDER BY expressions must appear in select list. > It is weird as the order by column appears in the select. No it doesn't. The ORDER BY expression is "UPPER(tag)" not just "tag". regards, tom lane