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
转载于:https://www.cnblogs.com/123456p/p/8649156.html
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
转载于:https://www.cnblogs.com/123456p/p/8649156.html