Re: removing duplicates and using sort - Mailing list pgsql-sql

From David Johnston
Subject Re: removing duplicates and using sort
Date
Msg-id 1379342569452-5771096.post@n5.nabble.com
Whole thread Raw
In response to removing duplicates and using sort  (Nathan Mailg <nathanmailg@gmail.com>)
Responses Re: removing duplicates and using sort
List pgsql-sql
Note that you could always do something like:

WITH original_query AS (
SELECT DISTINCT ...
)
SELECT *
FROM original_query
ORDER BY lastname, firstname;

OR

SELECT * FROM (   SELECT DISTINCT ....
) sub_query
ORDER BY lastname, firstname

I am thinking you cannot alter the existing ORDER BY otherwise your use of
"DISTINCT ON" begins to mal-function.  I dislike DISTINCT ON generally but
do not wish to ponder how you can avoid it, so I'd suggest just turning your
query into a sub-query like I show above.

David J.




--
View this message in context:
http://postgresql.1045698.n5.nabble.com/removing-duplicates-and-using-sort-tp5770931p5771096.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.



pgsql-sql by date:

Previous
From: "Edward W. Rouse"
Date:
Subject: Re: removing duplicates and using sort
Next
From: Nathan Mailg
Date:
Subject: Re: removing duplicates and using sort