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
全部评论

相关推荐

牛客868257804号:九个中铁八个中建
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务