Re: highest match in group

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Dave [Hawk-Systems]" <dave(at)hawk-systems(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: highest match in group
Date: 2003-12-10 16:37:11
Message-ID: 6954.1071074231@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Dave [Hawk-Systems]" <dave(at)hawk-systems(dot)com> writes:
> have a data table that records entries by date(unix timestamp) and customer
> number. each custnum will have several entries showing a running ledger type
> snapshot. we have the need to get the most recent entry from not one, but all
> unique customers, in the most cost effective manner.

If you don't mind using a Postgres-only construct, SELECT DISTINCT ON
is made for this. See the "weather report" example in the SELECT
reference page.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John Sidney-Woollett 2003-12-10 16:38:16 Update multiple columns with select statement?
Previous Message Tom Lane 2003-12-10 16:35:38 Re: Strange permission problem regarding pg_settings