From: | Scott Marlowe <smarlowe(at)g2switchworks(dot)com> |
---|---|
To: | sergey kapustin <master(dot)sergey(at)gmail(dot)com> |
Cc: | pgsql general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: ERROR: for SELECT DISTINCT, ORDER BY expressions |
Date: | 2006-06-08 20:47:13 |
Message-ID: | 1149799633.25526.265.camel@state.g2switchworks.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, 2006-06-07 at 10:09, 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
You could add another level of sub select here, to put the order by
random() outside the select distinct num. BUT, there's no need for the
distinct. The unions (not union all) guarantee a uniqe return set to
begin with.
Is this the actual query, or a simplified one?
If it's simplified, could we have the original one, and possible
indented in some way so as to make it easier to read?
From | Date | Subject | |
---|---|---|---|
Next Message | pobox@verysmall.org | 2006-06-08 20:47:18 | php 5.1.4 with PostgreSQL 8.1.4 causes Apache 1.3.36 to core dump |
Previous Message | Roy Souther | 2006-06-08 20:45:44 | Re: Fabian Pascal and RDBMS deficiencies in fully |