Re: SQL problem: bank account

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Erik G(dot) Burrows" <eburrows(at)erikburrows(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: SQL problem: bank account
Date: 2003-06-02 13:42:37
Message-ID: 7888.1054561357@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Erik G. Burrows" <eburrows(at)erikburrows(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Dmitry Tkach 2003-06-02 14:28:16 Re: SQL problem: bank account
Previous Message Rado Petrik 2003-06-02 13:34:15 Using & - operator