saber老虎钳梗:SQL!!!HELP!!!SOS

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/28 19:41:42
写出数据库查询语句,查询出的显示格式如下:
班级 90以上 80-89 70-79 60-69 不及格

select
a.cname as "class'
sum(case
when score>=90 then 1
else 0
end) 'more than 90'
sum(case
when score>=80 and score<90 then 1
else 0
end) 'between 80 and 90'
sum(case
when score>=70 and score<80 then 1
else 0
end) 'between 70 and 80'
sum(case
when score>=60 and score<70 then 1
else 0
end) 'between 60 and 70'
sum(case
when score>60 then 1
else 0
end)'fail'
from
class a
inner join
stu_class b
on a.cid=b.cid
inner join
stuscore c
on b.stuid=c.stuid
group by a.cname

是查询有多少人呢?还是信息 啊?