Re: [SQL] Finding the "most recent" rows
От | Julian Scarfe |
---|---|
Тема | Re: [SQL] Finding the "most recent" rows |
Дата | |
Msg-id | 37204BB5.B6CD57B9@scigen.co.uk обсуждение исходный текст |
Ответ на | Re: [SQL] Finding the "most recent" rows (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: [SQL] Finding the "most recent" rows
|
Список | pgsql-sql |
Tom Lane wrote: > > SELECT DISTINCT ON place * FROM table ORDER BY place, time DESC; > > might do the right thing. It *seems* to select the first row for each > value of place. I've never seen a spec for this feature, however, so > I'm not sure if it's reliable or not... Works a treat when I try it on the "real" database (using 6.4.2). It seems very efficient. I didn't realise that "DISTINCT ON" worked that way with an "ORDER BY". I must say I'm overwhelmed by the variety of constructive responses to my request. Thank you all very much. It beats the hell out of sitting as no 17 in a premium rate telephone queue for support from a vendor of a "commercial" product. -- Julian Scarfe
В списке pgsql-sql по дате отправления: