一、查询
1. 用一条SQL从这个stuCourse表获得这样结果
分别查出文理科的平均分,再将两个结果左连,只查需要的字段
1 SELECT 2 wen.`学号`, 3 wen.`文-平均分[语文]`, 4 li.`理-平均分[数学、物理]` 5 FROM 6 ( SELECT `NAME` AS '学号', AVG( score ) AS '文-平均分[语文]' FROM `courses` WHERE course = '语文' GROUP BY `NAME` ) wen 7 LEFT JOIN 8 ( SELECT `NAME` AS '学号', AVG( score ) AS '理-平均分[数学、物理]' FROM courses WHERE course IN ( '数学', '物理' ) GROUP BY `NAME` ) li 9 ON wen.学号 = li.学号;