sql 查分数段人数

select count(case 分数字段 when 100 then 1 end) as [满分],
count(case when 分数字段 between 90 and 99 then 1 end) as[90-99分],
count(case when 分数字段 between 80 and 89 then 1 end) as[80-89分],
count(case when 分数字段 between 70 and 79 then 1 end) as[70-79分],
count(case when 分数字段<70 then 1 end) as[70分以下]
from 学生分数表

 

使用union太慢

 

posted on 2017-11-16 11:53  bkin的笔记  阅读(4348)  评论(0编辑  收藏  举报