查询"01"课程比"02"课程成绩高的学生的信息及课程分数
-- 解法一:
select s1.*, s2.01_score, s2.02_score from student s1, ( select t1.s_id as s_id, t1.s_score as 01_score, t2.s_score as 02_score from score t1, score t2 where t1.s_id = t2.s_id and t1.c_id = '01' and t2.c_id = '02' and t1.s_score > t2.s_score ) s2 where s1.s_id = s2.s_id;
--参考解法
select a.* , b.s_score as 01 _score, c.s_score as 02 _score from student a join score b on a.s_id = b.s_id and b.c_id = '01' left join score c on a.s_id = c.s_id and c.c_id = '02' or c.c_id = null where b.s_score>c.s_score;
-- 2019/04/15