Re: Non-aggregate values attached to aggregates?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Non-aggregate values attached to aggregates?
Дата
Msg-id 1690.1103234276@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Non-aggregate values attached to aggregates?  (Benjamin Smith <lists@benjamindsmith.com>)
Список pgsql-general
Benjamin Smith <lists@benjamindsmith.com> writes:
> I have a list of students, and a list of enrollment records, and I'm trying to
> get a list of students and their most recent enrollment/disenrollment dates.

I don't know any nice way to solve this type of problem in bog-standard SQL.
But it's pretty easy to solve using Postgres' DISTINCT ON extension.
Look at the "weather reports" example in the SELECT reference page
for inspiration.

            regards, tom lane

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

Предыдущее
От: Benjamin Smith
Дата:
Сообщение: Non-aggregate values attached to aggregates?
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: Non-aggregate values attached to aggregates?