php ,mysql 谁能帮我分段统计各分数段的人数并显示出来 grade成绩表,sgrade学生成绩,cid课程号 20
展开全部
select count(*) from grade where cid = $cid group by sgrade;
你分数段是什么意思,是指60-80多少人,80-100多少人? 还是 61分 2人 ,62分0人 , 63分3人.....这样。
select
sum(case when sgrade < 100 and sgrade >89 then 1 else 0 end) as 'scroeA',
sum(case when sgrade < 90 and sgrade >79 then 1 else 0 end) as 'scroeB',
sum(case when sgrade < 80 and sgrade >69 then 1 else 0 end) as 'scroeC',
sum(case when sgrade < 70 and sgrade >59 then 1 else 0 end) as 'scroeD'
from grade where cid = $cid group by sgrade;
你分数段是什么意思,是指60-80多少人,80-100多少人? 还是 61分 2人 ,62分0人 , 63分3人.....这样。
select
sum(case when sgrade < 100 and sgrade >89 then 1 else 0 end) as 'scroeA',
sum(case when sgrade < 90 and sgrade >79 then 1 else 0 end) as 'scroeB',
sum(case when sgrade < 80 and sgrade >69 then 1 else 0 end) as 'scroeC',
sum(case when sgrade < 70 and sgrade >59 then 1 else 0 end) as 'scroeD'
from grade where cid = $cid group by sgrade;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询