![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, suppose a table that has records with some ID and a timestamp. id, Â* Â*ts 3, Â* Â*2012/01/03 5, Â* Â*2012/01/05 7, Â* Â*2012/01/07 3, Â* Â*2012/02/03 3, Â* Â*2012/01/05 5, Â* Â*2012/03/01 7, Â* Â*2012/04/04 to fetch every last row of those IDs I do: select Â* id, ts from Â* ( Â* select Â* id, ts, row_number() over ( partition by id Â* order by ts desc ) as nr from mytab ) as x where nr = 1 Is there a another way without a subselect? There might be more columns so the window-functions first/last won't help. -- Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql |
![]() |
| Thread Tools | |
| Display Modes | |
| |