X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F02638B9E50 for ; Fri, 4 Feb 2005 14:13:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16458-04 for ; Fri, 4 Feb 2005 14:13:39 +0000 (GMT) Received: from mail.tpgi.com.au (mail5.tpgi.com.au [203.12.160.101]) by svr1.postgresql.org (Postfix) with ESMTP id 0C10B8B9E39 for ; Fri, 4 Feb 2005 14:13:40 +0000 (GMT) Received: from [192.168.0.20] (203-219-213-46-qld.tpgi.com.au [203.219.213.46]) by mail.tpgi.com.au (8.12.10/8.12.10) with ESMTP id j14EDdnG031753 for ; Sat, 5 Feb 2005 01:13:39 +1100 Received: from 127.0.0.1 (AVG SMTP 7.0.300 [265.8.5]); Sat, 05 Feb 2005 00:13:37 +1000 Message-ID: <009401c50ac3$b841d5f0$1400a8c0@jac> From: "q2005" To: Subject: the best way to get the first record from each group Date: Sat, 5 Feb 2005 00:13:36 +1000 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=big5 X-TPG-Antivirus: Passed X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200502/110 X-Sequence-Number: 20221 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