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太慢

原文地址:https://www.cnblogs.com/hpbkin/p/7843633.html