I am working on an attendance project using MySQL. I am trying to pull data from an attendance table but I need only the latest date that the student has attended. So far I have the following SQL code:
Code:
SELECT StudentID, FirstName, LastName, ClassDate
FROM Students INNER JOIN Attendance USING (StudentID)
GROUP BY StudentID, ClassDate
ORDER BY StudentID, ClassDate
Which returns:
Code:
StudentID FirstName LastName ClassDate
4 Student One 2008-04-16
5 Student Two 2008-04-30
5 Student Two 2008-05-04
6 Student Three 2008-05-04
6 Student Three 2008-05-05
7 Student Four 2008-04-30
7 Student Four 2008-05-02
7 Student Four 2008-05-04
7 Student Four 2008-05-09
Which I would like the following returned:
Code:
StudentID FirstName LastName ClassDate
4 Student One 2008-04-16
5 Student Two 2008-05-04
6 Student Three 2008-05-05
7 Student Four 2008-05-09
Any help is greatly appreciated!!!