从一个表中得到这样一个结果集:(一个人一个记录有职务,是否被处分过等字段,统计符合条件的记录数)
职务 总数 被处分的人 未被处分的人
局长 50 20 30
所长 60 10 50
处长 100 15 85
select 职务, Count(*),
Count(case 处分 when 是 then 处分 else null end),
Count(case 处分 when 否 then 处分 else null end)
from table
group by 职务