怎么查询“001”课程比“002”课程成绩高的所有学生的学号?表结构如下:
sid(学生编号),cid(课程编号),score(分数);insertintoScoretable(‘01’,‘001’,87);insertintoScoretabl...
sid(学生编号), cid(课程编号) ,score(分数);
insert into Scoretable(‘01’,‘001’,87);
insert into Scoretable(‘01’,‘002’,86);
insert into Scoretable(‘02’,‘001’,88);
insert into Scoretable(‘02’,‘002’,90); 展开
insert into Scoretable(‘01’,‘001’,87);
insert into Scoretable(‘01’,‘002’,86);
insert into Scoretable(‘02’,‘001’,88);
insert into Scoretable(‘02’,‘002’,90); 展开
1个回答
展开全部
select a.sid, a.score as score1,b.score as score2 from (select * from scoretable where cid='001') a
left join
(select * from scoretable where cid='002')b
on a.sid=b.sid
where a.score>b.score
left join
(select * from scoretable where cid='002')b
on a.sid=b.sid
where a.score>b.score
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询