From: Jonathan Gardner <jgardner@smoothcorp.com>
To: listrec <listrec@epecon.de>
To: Erik G. Burrows <eburrows@erikburrows.com>
To: pgsql-sql@postgresql.org
Subject: Re: SQL problem: bank account
Date: Mon, 2 Jun 2003 06:20:56 -0700
Message-ID: <200306020620.56966.jgardner@smoothcorp.com> (raw)
In-Reply-To: <PCEJJIGCHIJCOOOGFAFEKENBCAAA.listrec@epecon.de>
References: <PCEJJIGCHIJCOOOGFAFEKENBCAAA.listrec@epecon.de>
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@smoothcorp.com - (425) 460-4780
Live Free, Use Linux!
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: jgardner@smoothcorp.com, listrec@epecon.de, eburrows@erikburrows.com
Subject: Re: SQL problem: bank account
In-Reply-To: <200306020620.56966.jgardner@smoothcorp.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox