Re: DISTINCT ... ORDER BY

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: DISTINCT ... ORDER BY
Дата
Msg-id 20031105175327.GA6933@wolff.to
обсуждение исходный текст
Ответ на Re: DISTINCT ... ORDER BY  (Nabil Sayegh <postgresql@e-trolley.de>)
Список pgsql-novice
On Wed, Nov 05, 2003 at 18:37:26 +0100,
  Nabil Sayegh <postgresql@e-trolley.de> wrote:
> 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?

I don't think you are asking the right question. However, this ordering
will result in the correct record with a particular value for col_1
being used for the next step. This is all that is needed, since in the
next step the data will be sorted according to the original criteria.

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

Предыдущее
От: Nabil Sayegh
Дата:
Сообщение: Re: DISTINCT ... ORDER BY
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: DISTINCT ... ORDER BY