Re: ERROR: for SELECT DISTINCT, ORDER BY expressions must - Mailing list pgsql-admin

From Stephan Szabo
Subject Re: ERROR: for SELECT DISTINCT, ORDER BY expressions must
Date
Msg-id 20050314065442.U6400@megazone.bigpanda.com
Whole thread Raw
In response to ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list  (Gourish Singbal <gourish@gmail.com>)
List pgsql-admin
On Mon, 14 Mar 2005, Gourish Singbal wrote:

> The Query needs to have the distinct clause in the select statement
> and the UPPER clause in the order by clause.
>
> eg.
> select distinct id, type from user_list order by UPPER(type)
>
> Please let me know if there is any solution to this issue
> thanks in advance.

I think you can break the select distinct into a subselect like
 select * from (select distinct id, type from user_list) a order by
upper(type)

Note, that if you were to ever have two strings that were considered the
same in type but which upper-case differently, the query would give
non-deterministic results.

pgsql-admin by date:

Previous
From: David Wagoner
Date:
Subject: Log to Syslog or rotatelogs? Advice Please
Next
From: Thomas F.O'Connell
Date:
Subject: Re: Performance Question