SQL面试50题-35
35、查询所有学生的课程及分数情况(重点)
SELECT st.s_name ,MAX(CASE WHEN sc.c_id = '01' THEN sc.s_score ELSE NULL END ) AS "语文" ,MAX(CASE WHEN sc.c_id = '02' THEN sc.s_score ELSE NULL END ) AS "数学" ,MAX(CASE WHEN sc.c_id = '03' THEN sc.s_score ELSE NULL END ) AS "英语" FROM Student st INNER JOIN Score sc ON sc.s_id = st.s_id INNER JOIN Course co ON co.c_id = sc.c_id GROUP BY st.s_name