Joining tables based on the maximum value

后端 未结 6 1725
暖寄归人
暖寄归人 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 23:00

    Try this,

    Select student.name, max(result.score) As Score from Student
            INNER JOIN
        result
            ON student.ID = result.student_id
    GROUP BY
        student.name
    

提交回复
热议问题