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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: aymeric(at)javablackbelt(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: SELECT DISTINCT ... ORDER BY UPPER(column_name) fails
Date: 2007-11-04 17:12:31
Message-ID: 15015.1194196351@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Aymeric Levaux <aymeric(at)javablackbelt(dot)com> 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Volkan YAZICI 2007-11-04 17:57:19 Partitioning and Foreign Keys
Previous Message Aymeric Levaux 2007-11-04 16:49:02 SELECT DISTINCT ... ORDER BY UPPER(column_name) fails