SQL面试题_sql查询总分大于200的所有学生-CSDN博客

SELECT stu.student_no, stu.student_name, SUM(sc.score) total_socre

FROM student stu

LEFT JOIN score sc ON stu.id = sc.student_id

GROUP BY stu.student_no, stu.student_name HAVING total_score > 200

ORDER BY total_socre desc;

其中考察点是主键与外键的关联(外连接)、分组之后的过滤(GROUP BY、HAVING、对结果排序(升序降序)