Re: filter duplicates by priority - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: filter duplicates by priority
Date
Msg-id 20090714155630.GB9600@svana.org
Whole thread Raw
In response to filter duplicates by priority  ("Clark Slater" <pg@slatech.com>)
List pgsql-general
On Tue, Jul 14, 2009 at 10:04:12AM -0400, Clark Slater wrote:
> Hello-
>
> I am trying to use DISTINCT ON to filter out *potential* duplicate values
> from a set of sub queries.  There are certain cases where there can be
> repetitive part numbers that are priced differently.  I'm trying to start
> with the full list, ordered by priority, and then remove any repeats that
> have a lesser priority.

I think what you need to do is order by part_number first, do the
DISTINCT ON () and then do an ORDER BY priority around that.

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Attachment

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: filter duplicates by priority
Next
From: Sam Mason
Date:
Subject: Re: filter duplicates by priority