Re: Group By Question

Поиск
Список
Период
Сортировка
От Chris Velevitch
Тема Re: Group By Question
Дата
Msg-id AANLkTikk5mU450gkrc9B1e=L7DsKzuF5ze-F_E4-r6n9@mail.gmail.com
обсуждение исходный текст
Ответ на Group By Question  ("Andrew E. Tegenkamp" <andrew@g3.com>)
Список pgsql-general
That's getting too complicated. It can be done simply as:

SELECT DISTINCT(test.people.id) test.people.id, test.people.name, test.likes.ref
FROM test.people LEFT JOIN test.likes ON test.people.id = test.likes.ref
ORDER BY test.people.id, test.likes.date DESCENDING

Assuming people.id is unique, the order by clause makes the first row
of every group the most recent like and distinct expression keeps only
the first row for each person.



Chris
--
Chris Velevitch
Manager - Adobe Platform Users Group, Sydney
m: 0415 469 095
www.apugs.org.au

Adobe Platform Users Group, Sydney
October 2010: Flash Builder for SalesForce
Date: 25th October, 6pm for 6:30 start
Details and RSVP coming soon

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

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: querying the version of libpq
Следующее
От: "Greg Sabino Mullane"
Дата:
Сообщение: Re: querying the version of libpq