Re: DISTINCT ... ORDER BY

Поиск
Список
Период
Сортировка
От Nabil Sayegh
Тема Re: DISTINCT ... ORDER BY
Дата
Msg-id 3FA93556.20709@e-trolley.de
обсуждение исходный текст
Ответ на Re: DISTINCT ... ORDER BY  (Bruno Wolff III <bruno@wolff.to>)
Ответы Re: DISTINCT ... ORDER BY  (Bruno Wolff III <bruno@wolff.to>)
Список 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


В списке pgsql-novice по дате отправления:

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: DISTINCT ... ORDER BY
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: DISTINCT ... ORDER BY