https://zhidao.baidu.com/question/2144315898629665548.html

select stuClass,count(stuName) 班级人数,sum(case when stuSex='男' then 1 else 0 end ) 男生人数,sum(case when stuSex='女' then 1 else 0 end ) 女生人数 from student group by stuClass