SELECT DISTINCT ... ORDER BY UPPER(column_name) fails

From: Aymeric Levaux <aymeric(at)javablackbelt(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: SELECT DISTINCT ... ORDER BY UPPER(column_name) fails
Date: 2007-11-04 16:49:02
Message-ID: 472DF7FE.1050504@javablackbelt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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?

--
Aymeric Levaux
<http://www.javablackbelt.com>

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2007-11-04 17:12:31 Re: SELECT DISTINCT ... ORDER BY UPPER(column_name) fails
Previous Message Tom Lane 2007-11-04 16:35:36 Re: omitting redundant join predicate