Re: ORDER BY and DISTINCT ON - Mailing list pgsql-hackers

From Bruno Wolff III
Subject Re: ORDER BY and DISTINCT ON
Date
Msg-id 20031215140334.GA20111@wolff.to
Whole thread Raw
In response to Re: ORDER BY and DISTINCT ON  (Bruno Wolff III <bruno@wolff.to>)
Responses Re: ORDER BY and DISTINCT ON
List pgsql-hackers
On Mon, Dec 15, 2003 at 06:14:59 -0600, Bruno Wolff III <bruno@wolff.to> wrote:
> 
> Doing things as above is pretty much the same as normal distinct on
> for purposes of which rows get selected. Of the possible rows that
> might get returned for a specific set of values from the distinct on
> expressions you will get the row that is first as ordered by the
> expressions in the order by clause. If the order by clause isn't selective
> enough there may be several rows that could be selected, but that is true
> for how distinct on works now.

Specifically the interpretation I think makes sense is that
SELECT DISTINCT ON (a, b, c) * FROM tablename ORDER BY d, e, f
should be treated as equvialent to
SELECT * FROM (SELECT DISTINCT ON (a, b, c) FROM tablename ORDER BY a, b, c, d, e, f) AS t ORDER BY d, e, f


pgsql-hackers by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: ORDER BY and DISTINCT ON
Next
From: Tom Lane
Date:
Subject: Re: ORDER BY and DISTINCT ON