From: | Jonathan Gardner <jgardner(at)smoothcorp(dot)com> |
---|---|
To: | "listrec" <listrec(at)epecon(dot)de>, "Erik G(dot) Burrows" <eburrows(at)erikburrows(dot)com>, <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: SQL problem: bank account |
Date: | 2003-06-02 13:20:56 |
Message-ID: | 200306020620.56966.jgardner@smoothcorp.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Monday 02 June 2003 00:49, listrec wrote:
> How about:
>
> select max(transaction_id) from bank_account group by customer_id
>
And if you want the rest of the data in the rows:
SELECT b.*
FROM bank_account b
JOIN (
SELECT max(transaction_id) AS transaction_id
FROM bank_account
GROUP BY customer_id
) AS subselect ON subselect.transaction_id=b.transaction_id
;
I use a similar query here at work to find the first time a guy has visited
our site through an advertiser.
--
Jonathan M. Gardner
Smooth Corporation - Perl Programmer
jgardner(at)smoothcorp(dot)com - (425) 460-4780
Live Free, Use Linux!
From | Date | Subject | |
---|---|---|---|
Next Message | Rado Petrik | 2003-06-02 13:34:15 | Using & - operator |
Previous Message | Richard Huxton | 2003-06-02 07:51:52 | Re: CASE returning multiple values (was SQL Help) |