Re: ORDER BY and DISTINCT ON

Поиск
Список
Период
Сортировка
Искать
От
Bruno Wolff III
Тема
Re: ORDER BY and DISTINCT ON
Дата
Msg-id
20031214144030.GA9284@wolff.to
Ответ на
Список
Дерево обсуждения
ORDER BY and DISTINCT ON Neil Conway <neilc@samurai.com>
Re: ORDER BY and DISTINCT ON Bruno Wolff III <bruno@wolff.to>
Re: ORDER BY and DISTINCT ON Greg Stark <gsstark@mit.edu>
Re: ORDER BY and DISTINCT ON Bruno Wolff III <bruno@wolff.to>
Re: ORDER BY and DISTINCT ON Tom Lane <tgl@sss.pgh.pa.us>
Re: ORDER BY and DISTINCT ON Bruno Wolff III <bruno@wolff.to>
Re: ORDER BY and DISTINCT ON Tom Lane <tgl@sss.pgh.pa.us>
Re: ORDER BY and DISTINCT ON Bruno Wolff III <bruno@wolff.to>
Re: ORDER BY and DISTINCT ON Bruno Wolff III <bruno@wolff.to>
Re: ORDER BY and DISTINCT ON Tom Lane <tgl@sss.pgh.pa.us>
Re: ORDER BY and DISTINCT ON Neil Conway <neilc@samurai.com>
Re: ORDER BY and DISTINCT ON Tom Lane <tgl@sss.pgh.pa.us>
Re: ORDER BY and DISTINCT ON Neil Conway <neilc@samurai.com>
On Sat, Dec 13, 2003 at 22:12:32 -0500, Greg Stark  wrote:
> 
> So, like DISTINCT ON, GROUP BY also insists on the user providing the ORDER BY
> clause. I suppose you could argue postgres could implicitly introduce an extra
> sort step when the user-provided ORDER BY doesn't match the GROUP BY or
> DISTINCT ON clause but it seems like the user is probably confused if he
> really wants a random record and then sort on columns that weren't sorted
> previous to the DISTINCT ON.

You can make the result deterministic by using an initial order by
that uses the distinct expressions followed by the order by expressions.
After that is used to get which records will be returned, a second sort
is done using just the expressions on the order by clause.

В списке pgsql-hackers по дате отправления
От: Kurt Roeckx
Дата:
Сообщение: Re: Walker/mutator prototype.
От: Greg Stark
Дата:
Сообщение: Re: Walker/mutator prototype.
FAQ