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 5E61D5E46D3 for ; Tue, 17 Aug 2004 07:44:46 -0300 (ADT) 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 06933-10 for ; Tue, 17 Aug 2004 10:44:38 +0000 (GMT) Received: from web40110.mail.yahoo.com (web40110.mail.yahoo.com [66.218.78.44]) by svr1.postgresql.org (Postfix) with SMTP id 371465E46CD for ; Tue, 17 Aug 2004 07:44:34 -0300 (ADT) Message-ID: <20040817104437.93301.qmail@web40110.mail.yahoo.com> Received: from [130.37.20.20] by web40110.mail.yahoo.com via HTTP; Tue, 17 Aug 2004 03:44:37 PDT Date: Tue, 17 Aug 2004 03:44:37 -0700 (PDT) From: Dino Vliet Subject: only last records in subgroups To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/159 X-Sequence-Number: 18656 Hi there, I'm having hard times with the following query: I want to select only the last records from a subgroup in a table. But because the subgroup contains different number of records for every id, I don't know how to specify that. For example, check the following table, id, day x,300 x,250, x,0 y,250 y,4 I only want the records x,0 and y,4 but how do I manage this in sql? I was hoping for a keyword LAST or so, where I can specify that when I've ordered my results with order by, I could only get the last of the subgroups (the first one is easy because I could use limit 1) Thanks in advance __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail