Re: ERROR: for SELECT DISTINCT, ORDER BY expressions must

From: Bricklen Anderson <banderson(at)presinet(dot)com>
To: sergey kapustin <master(dot)sergey(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ERROR: for SELECT DISTINCT, ORDER BY expressions must
Date: 2006-06-08 19:56:20
Message-ID: 448880E4.4020304@presinet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

sergey kapustin wrote:
> Hi all!
> can anybody say me what's wrong with this query. I just try to take
> unique values from table column and print them in random order
>
> select distinct num from (select 1 as num union select 2 as num union
> select 1 as num union select 3) t order by random();
> ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select
> list
>
> thank you

select num from
(select distinct num
from (select 1 as num union select 2 as num union select 1 as num
union select 3 as num) a) t
order by random();

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-06-08 20:22:21 Re: SessionID, pretty please
Previous Message Harry Hehl 2006-06-08 19:42:03