From: | Klint Gore <kg(at)kgb(dot)une(dot)edu(dot)au> |
---|---|
To: | lists(at)benjamindsmith(dot)com |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Non-aggregate values attached to aggregates? |
Date: | 2004-12-16 22:36:05 |
Message-ID: | 41C20DD5326.DCDAKG@129.180.47.120 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, 16 Dec 2004 13:38:19 -0800, Benjamin Smith <lists(at)benjamindsmith(dot)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(at)kgb(dot)une(dot)edu(dot)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 : :
+---------------------------------------+-----------------+
From | Date | Subject | |
---|---|---|---|
Next Message | Jamie Deppeler | 2004-12-16 22:41:22 | MD5 |
Previous Message | Net Virtual Mailing Lists | 2004-12-16 22:21:22 | tsearch2 avoiding firing of triggers..... |