Re: the best way to get the first record from each group

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: q2005 <q2005(at)tpg(dot)com(dot)au>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: the best way to get the first record from each group
Date: 2005-02-08 01:16:26
Message-ID: 20050208011626.GA43996@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, Feb 08, 2005 at 10:36:17AM +1000, q2005 wrote:
>
> Is there any better alternative to get the first record from each group?

PostgreSQL has a non-standard SELECT DISTINCT ON query for just
this purpose.

http://www.postgresql.org/docs/8.0/static/queries-select-lists.html#QUERIES-DISTINCT
http://www.postgresql.org/docs/8.0/static/sql-select.html#SQL-DISTINCT

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Premsun Choltanwanich 2005-02-08 01:32:33 Re: How can I use large object on PostgreSQL Linux
Previous Message q2005 2005-02-08 00:36:17 the best way to get the first record from each group