Re: Best way to get the latest revision from a table

Поиск
Список
Период
Сортировка
От Shaun Thomas
Тема Re: Best way to get the latest revision from a table
Дата
Msg-id 4D30D708.3020704@peak6.com
обсуждение исходный текст
Ответ на Best way to get the latest revision from a table  (Nikolas Everett <nik9000@gmail.com>)
Ответы Re: Best way to get the latest revision from a table
Список pgsql-performance
On 01/14/2011 03:17 PM, Nikolas Everett wrote:

> SELECT *
>    FROM request
>    JOIN (SELECT a, MAX(b) as b FROM test GROUP BY a) max USING (a)
>    JOIN test USING (a, b);

This actually looks like a perfect candidate for DISTINCT ON.

SELECT DISTINCT ON (a, b) a, b, revision
   FROM test
  ORDER BY a, b DESC;

Maybe I'm just misunderstanding your situation, though.

--
Shaun Thomas
OptionsHouse | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604
312-676-8870
sthomas@peak6.com

______________________________________________

See  http://www.peak6.com/email_disclaimer.php
for terms and conditions related to this email

В списке pgsql-performance по дате отправления:

Предыдущее
От: "Kevin Grittner"
Дата:
Сообщение: Re: Best way to get the latest revision from a table
Следующее
От: "Kevin Grittner"
Дата:
Сообщение: Re: Best way to get the latest revision from a table