笔试题:SQL统计各科目中各分数线人数

来源:互联网 发布:ucloud云计算 校园 编辑:程序博客网 时间:2024/04/29 00:09

题目如图:

这里写图片描述

第一题:

select c.Cno,c.Cname,    count(case when s.score between 85 and 100 then 1 end) as '[100-85分]',    count(case when s.score between 70 and 85 then 1 end) as '[85-70分]',    count(case when s.score between 60 and 70 then 1 end) as '[70-60分]',    count(case when s.score<60 then 1 end) as '[60分以下]' from Course c, SC s where c.Cno = s.Cnogroup by c.Cno,c.Cname

第二题:

select Sno,avg(score) from SC where Sno in (    select s.Sno    from SC s    where s.score<60    group by s.Sno having count(*)>=2) group by Sno
1 0
原创粉丝点击