| From: | Jonathan Gardner <jgardner(at)jonathangardner(dot)net> |
|---|---|
| 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 16:40:58 |
| Message-ID: | 200306020940.58614.jgardner@jonathangardner.net |
| Views: | Whole Thread | Raw Message | 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 Gardner <jgardner(at)jonathangardner(dot)net>
(was jgardn(at)alumni(dot)washington(dot)edu)
Live Free, Use Linux!
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Erik G. Burrows | 2003-06-02 16:58:39 | Re: SQL problem: bank account |
| Previous Message | Samuel Tardieu | 2003-06-02 15:47:35 | Maintaining a counter up-to-date |