Re: removing duplicates and using sort

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: removing duplicates and using sort
Date: 2013-09-16 14:42:49
Message-ID: 1379342569452-5771096.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Nathan Mailg 2013-09-17 16:03:15 Re: removing duplicates and using sort
Previous Message Edward W. Rouse 2013-09-16 14:04:40 Re: removing duplicates and using sort