Search Postgresql Archives

Re: using window-functions to get freshest value - how?

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

 



Massa, Harald Armin, 20.11.2009 11:07:
I have a table

CREATE TABLE rfmitzeit
(
 id_rf inet NOT NULL,
 id_bf integer,
 wert text,
 letztespeicherung timestamp without time zone
 CONSTRAINT repofeld_id_rf PRIMARY KEY (id_rf),
 );
where for one id_bf there are stored mutliple values ("wert") at multiple dates: id_bf, wert, letztespeicherung:
   98,  'blue', 2009-11-09
   98,  'red', 2009-11-10
now I have a select to get the "youngest value" for every id_bf:

Not tested:

SELECT id_bf, wert,
      max(letztespeicherung) over (partition by id_bf)
FROM rfmitzeit

Regards
Thomas


--
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