Re: order by, but eliminating dupes

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: order by, but eliminating dupes
Дата
Msg-id 20030904031932.GA28420@wolff.to
обсуждение исходный текст
Ответ на order by, but eliminating dupes  (LH <_pgsql-novice_@geekhouse.no-ip.com>)
Список pgsql-novice
On Wed, Sep 03, 2003 at 22:52:44 -0400,
  LH <_pgsql-novice_@geekhouse.no-ip.com> wrote:
> So lets say I got a table A(x,y,z, Q) ordered by column Q, with contents
> like so:
>
> But that kills the order of the subquery. I've tried group by x,y,z but
> then I can't ORDER BY Q.

I think you can do something like this:

select x, y, z from
  (select distinct on (x, y, z) x, y, z, q order by x, y, z, q)
  order by q;

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

Предыдущее
От: glenn
Дата:
Сообщение: Editing functions
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Using NOT IN