Re: Non-aggregate values attached to aggregates? - Mailing list pgsql-general

From Tom Lane
Subject Re: Non-aggregate values attached to aggregates?
Date
Msg-id 1690.1103234276@sss.pgh.pa.us
Whole thread Raw
In response to Non-aggregate values attached to aggregates?  (Benjamin Smith <lists@benjamindsmith.com>)
List 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 by date:

Previous
From: Benjamin Smith
Date:
Subject: Non-aggregate values attached to aggregates?
Next
From: Michael Fuhr
Date:
Subject: Re: Non-aggregate values attached to aggregates?