统计出每个班分别有男女生各多少名

select classID,
sum(case when sex=1 then 1 else 0 end) as '男',
sum(case when sex=2 then 1 else 0 end) as '女'
from student group by classID
posted @ 2018-03-26 10:16  奔奔老王  阅读(281)  评论(0编辑  收藏  举报