Re: Efficiently obtaining (any) one record per group. - Mailing list pgsql-general

From Scott Marlowe
Subject Re: Efficiently obtaining (any) one record per group.
Date
Msg-id AANLkTimLuEhDOPC_Z=GMcymasETv5Hmww1=6rRT8-E20@mail.gmail.com
Whole thread Raw
In response to Efficiently obtaining (any) one record per group.  (Allan Kamau <kamauallan@gmail.com>)
Responses Re: Efficiently obtaining (any) one record per group.
List pgsql-general
On Sat, Jul 24, 2010 at 12:56 AM, Allan Kamau <kamauallan@gmail.com> wrote:
> Hi all,
>
> I have a large table that contains redundancies as per one field.
>
> I am looking for a way to identify (or extract) a non redundant set of
> rows ( _any_ one record per group) from this table and for each record
> of this "distinct" set of rows, I would like to capture it's other
> fields.

Would "Select distinct on ... " work for you?

http://www.postgresql.org/docs/8.4/static/sql-select.html

search the page for "distinct on".

pgsql-general by date:

Previous
From: Allan Kamau
Date:
Subject: Efficiently obtaining (any) one record per group.
Next
From: Alban Hertroys
Date:
Subject: Re: Blocked inserts on tables with FK to tables for which UPDATE has been revoked