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