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