Re: Non-aggregate values attached to aggregates?
От | Klint Gore |
---|---|
Тема | Re: Non-aggregate values attached to aggregates? |
Дата | |
Msg-id | 41C20DD5326.DCDAKG@129.180.47.120 обсуждение исходный текст |
Ответ на | Non-aggregate values attached to aggregates? (Benjamin Smith <lists@benjamindsmith.com>) |
Список | pgsql-general |
On Thu, 16 Dec 2004 13:38:19 -0800, Benjamin Smith <lists@benjamindsmith.com> wrote: > 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. just subselect the max date for the student_id in the where clause. select students.name, enrollments.start, enrollments.finish >from students, enrollments where enrollments.students_id = students.id and enrollments.start = (select max(e1.start) from enrollments e1 where e1.student_id = students.id) klint. +---------------------------------------+-----------------+ : Klint Gore : "Non rhyming : : EMail : kg@kgb.une.edu.au : slang - the : : Snail : A.B.R.I. : possibilities : : Mail University of New England : are useless" : : Armidale NSW 2351 Australia : L.J.J. : : Fax : +61 2 6772 5376 : : +---------------------------------------+-----------------+
В списке pgsql-general по дате отправления: