只需对person_id进行分组,当然可以在内部查询中进行:
select a.courseid, a.lesson, a.personid, a.thedate from ( select personid, courseid, min(thedate) as earliestdate from attendance group by personid, courseid) as x inner join attendance as a on (a.personid = x.personid and a.thedate = x.thedate and a.courseid=x.course_id)



