Re: order by, but eliminating dupes - Mailing list pgsql-novice

From Bruno Wolff III
Subject Re: order by, but eliminating dupes
Date
Msg-id 20030904031932.GA28420@wolff.to
Whole thread Raw
In response to order by, but eliminating dupes  (LH <_pgsql-novice_@geekhouse.no-ip.com>)
List 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 by date:

Previous
From: glenn
Date:
Subject: Editing functions
Next
From: Tom Lane
Date:
Subject: Re: Using NOT IN