From: | Nabil Sayegh <postgresql(at)e-trolley(dot)de> |
---|---|
To: | Bruno Wolff III <bruno(at)wolff(dot)to> |
Cc: | pgsql-novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: DISTINCT ... ORDER BY |
Date: | 2003-11-05 17:37:26 |
Message-ID: | 3FA93556.20709@e-trolley.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Bruno Wolff III wrote:
> I made a mistake in my example. In the distinct on subselect you have to
> order by the column(s) in the distinct on argument first. So in your example
> above the subselect should be:
> SELECT DISTINCT ON (col_1) col_1 FROM tab ORDER BY col_1, col_2='foo' DESC,
> col_1='bar' DESC, col_3='blah' DESC;
Hm, are you sure that this 'non-intended' ordering is reversible?
> In the outer select you use just the order by items that you want. Also
> note that the subselect will need to list all of the columns used in the
> order by in the outer select.
--
e-Trolley Sayegh & John, Nabil Sayegh
Tel.: 0700 etrolley /// 0700 38765539
Fax.: +49 69 8299381-8
PGP : http://www.e-trolley.de
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2003-11-05 17:53:27 | Re: DISTINCT ... ORDER BY |
Previous Message | Bruno Wolff III | 2003-11-05 17:12:25 | Re: DISTINCT ... ORDER BY |