agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: David Johnston <polobo@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Re: removing duplicates and using sort
Date: Mon, 16 Sep 2013 07:42:49 -0700 (PDT)
Message-ID: <1379342569452-5771096.post@n5.nabble.com> (raw)
In-Reply-To: <CAN8Rhd2n84Yxd4QP0SXuyuO+K4f3scQnAYAwq53GDFojOSkAjw@mail.gmail.com>
References: <CAN8Rhd2n84Yxd4QP0SXuyuO+K4f3scQnAYAwq53GDFojOSkAjw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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.
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
view thread (4+ messages) latest in thread
Message-ID: <1379342569452-5771096.post@n5.nabble.com>
Permalink: ../1379342569452-5771096.post@n5.nabble.com/
Also on: postgresql.org/message-id/1379342569452-5771096.post@n5.nabble.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: polobo@yahoo.com
Subject: Re: removing duplicates and using sort
In-Reply-To: <1379342569452-5771096.post@n5.nabble.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox