X-Original-To: pgsql-sql@postgresql.org Received: from localhost (developer.postgresql.org [64.117.224.193]) by developer.postgresql.org (Postfix) with ESMTP id 92E3A926198 for ; Mon, 2 Jun 2003 09:43:08 -0400 (EDT) Received: from developer.postgresql.org ([64.117.224.193]) by localhost (developer.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 90320-02 for ; Mon, 2 Jun 2003 09:42:56 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by developer.postgresql.org (Postfix) with ESMTP id C1860926231 for ; Mon, 2 Jun 2003 09:42:38 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h52DgbU6007889; Mon, 2 Jun 2003 09:42:37 -0400 (EDT) To: "Erik G. Burrows" Cc: pgsql-sql@postgresql.org Subject: Re: SQL problem: bank account In-reply-to: <1054531815.13212.27.camel@griffin.jedi-group.com> References: <1054531815.13212.27.camel@griffin.jedi-group.com> Comments: In-reply-to "Erik G. Burrows" message dated "01 Jun 2003 22:30:15 -0700" Date: Mon, 02 Jun 2003 09:42:37 -0400 Message-ID: <7888.1054561357@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new X-Archive-Number: 200306/17 X-Sequence-Number: 13775 "Erik G. Burrows" writes: > I need to get the most recent transaction for each customer. I need only > the transaction ID, but the entire row would be best. If you don't mind a not-standard-SQL solution, the SELECT DISTINCT ON construct is designed for this sort of thing. See the "weather report" example in the SELECT reference page. regards, tom lane