pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: q2005 <q2005@tpg.com.au>
To: pgsql-sql@postgresql.org
Subject: the best way  to get the first record from each group
Date: Sat, 5 Feb 2005 00:13:36 +1000
Message-ID: <009401c50ac3$b841d5f0$1400a8c0@jac> (raw)

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




view thread (5+ messages)  latest in thread

Message-ID: <009401c50ac3$b841d5f0$1400a8c0@jac>
Permalink:  ../009401c50ac3$b841d5f0$1400a8c0@jac/
Also on:    postgresql.org/message-id/009401c50ac3$b841d5f0$1400a8c0@jac

 · 

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: q2005@tpg.com.au
  Subject: Re: the best way  to get the first record from each group
  In-Reply-To: <009401c50ac3$b841d5f0$1400a8c0@jac>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox