Re: ORDER BY and DISTINCT ON

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: ORDER BY and DISTINCT ON
Дата
Msg-id 20031214144030.GA9284@wolff.to
обсуждение исходный текст
Ответ на Re: ORDER BY and DISTINCT ON  (Greg Stark <gsstark@mit.edu>)
Список pgsql-hackers
On Sat, Dec 13, 2003 at 22:12:32 -0500, Greg Stark <gsstark@mit.edu> 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.