'distinct on' and 'order by' conflicts of interest

Поиск
Список
Период
Сортировка
От stephen@thunkit.com
Тема 'distinct on' and 'order by' conflicts of interest
Дата
Msg-id 3068.67.21.238.59.1104511701.squirrel@mail.thunkit.com
обсуждение исходный текст
Ответы Re: 'distinct on' and 'order by' conflicts of interest
Re: 'distinct on' and 'order by' conflicts of interest
Список pgsql-general
It has come up several times on the various postgresql lists that in order
to get around the requirement of DISTINCT ON parameters matching the first
ORDER BY parameters, wrap the distinct query in a new 'order by' query:

select * from (select distinct on (a) a,b,c from foo order by a) order by c

however, this will not work when ordering by 'a' will put the wrong record
first, making it choose the wrong record via distinct on.  The 'order by
c' superquery no longer has the correct recordset to sort.

I cannot figure out how to have postgresql first sort the results (on
something other than the 'distinct on' parameters) and then do a recordset
culling by only part of the record.  Does anyone have the syntax for this?

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

Предыдущее
От: Jaime Casanova
Дата:
Сообщение: Re: [PATCHES] reqd patch
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: 'distinct on' and 'order by' conflicts of interest