Search Postgresql Archives

Re: Need help with what I think is likely a simple query - for each distinct val, return only the record with the most recent date.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 13/09/11 10:54, Reid Thompson wrote:
Could someone point me in the right direction..
Thanks - reid

Given the example data,
how do I write a query that will give me the resultset:
[snip]
> I.E. for each distinct val, return the record with the most recent date.

Isn't it something simple like this?

SELECT val, max(date) GROUP BY val;


-Toby

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux