SELECT student_id, course_id, MAX(grade)FROM EnrollmentsGROUP BY student_id;
再JOIN两表
SELECT e.student_id, MIN(e.course_id) as course_id, e.gradeFROM Enrollments e JOIN ( SELECT student_id, course_id, MAX(grade) AS max_grade FROM Enrollments GROUP BY student_id) AS tON e.student_id=t.student_id AND e.grade=t.max_gradeGROUP BY e.student_idORDER BY e.student_id;