第一题
select * from Student right join
(select t1.sid,class1,class2 from
(select sid,score as class1 from sc where cid ='01') t1,
(select sid,score as class2 from sc where cid ='02') t2
where t1.SId = t2.SId AND class1>class2) a
on Student.sid=a.sid;
第二题
select (select sname from Student where sid=t1.sid) sname,t1.cname,t1.score1,t2.cname,t2.score2 from
(select a.sid,b.cname,a.score score1 from SC a,Course b where a.cid='01' and a.cid=b.cid) t1,
(select a.sid,b.cname,a.score score2 from SC a,Course b where a.cid='02' and a.cid=b.cid) t2
where t1.sid=t2.sid;
50道sql
最新推荐文章于 2022-11-16 21:34:46 发布