Joining tables based on the maximum value

后端 未结 6 1726
暖寄归人
暖寄归人 2021-02-08 22:00

Here\'s a simplified example of what I\'m talking about:

Table: students      exam_results
_____________       ____________________________________
| id | name |         


        
6条回答
  •  一个人的身影
    2021-02-08 22:54

    Select Name, T.Score, er. date 
    from Students S inner join
              (Select Student_ID,Max(Score) as Score from Exam_Results
               Group by Student_ID) T 
    On S.id=T.Student_ID inner join Exam_Result er
    On er.Student_ID = T.Student_ID And er.Score=T.Score
    

提交回复
热议问题