Re: SQL problem: bank account - Mailing list pgsql-sql

From Tom Lane
Subject Re: SQL problem: bank account
Date
Msg-id 7888.1054561357@sss.pgh.pa.us
Whole thread Raw
In response to SQL problem: bank account  ("Erik G. Burrows" <eburrows@erikburrows.com>)
Responses Re: SQL problem: bank account
List pgsql-sql
"Erik G. Burrows" <eburrows@erikburrows.com> 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


pgsql-sql by date:

Previous
From: Rado Petrik
Date:
Subject: Using & - operator
Next
From: Dmitry Tkach
Date:
Subject: Re: SQL problem: bank account