the best way to get the first record from each group

From: "q2005" <q2005(at)tpg(dot)com(dot)au>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: the best way to get the first record from each group
Date: 2005-02-04 14:13:36
Message-ID: 009401c50ac3$b841d5f0$1400a8c0@jac
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,
Is there any better alternative to get the first record from each group?
"subno" is an integer, record with the smallest subno in each group is the
first record in the group.

select itemno, measureunit, extaxprice from itmt_purchase
where subno in (select min(subno)as subno
from itmt_purchase
group by itemno order by itemno)
order by itemno, measureunit;

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.8.5 - Release Date: 03/02/05

Browse pgsql-sql by date

  From Date Subject
Next Message Magnus Hagander 2005-02-04 14:48:44 Re: getting back autonumber just inserted
Previous Message Richard_D_Levine 2005-02-04 14:11:32 Re: getting back autonumber just inserted