1、查询"01"课程比"02"课程成绩高的学生的信息及课程分数
我的答案:
select st.*, sc.s_score '语文', sc2.score2 '数学', inner join score sc on sc.s_id =st.s_id and sc.c_id='01' inner join score sc2 on sc2.s_id =st.s_id and sc2.c_id='02' where sc.s_score> sc2.s_score
标准答案:
SELECT st.*, sc.s_score AS '语文', sc2.s_score AS '数学' FROM student st LEFT JOIN score sc ON sc.s_id=st.s_id AND sc.c_id='01' LEFT JOIN score sc2 ON sc2.s_id=st.s_id AND sc2.c_id='02' WHERE sc.s_score>sc2.s_score