--oralce case when,分开统计男女生人数
select grade,count(
case
when sex=1 then 1
--else null
end
) "男生数",count(
case
when sex = 2 then 1
--else null
end
) "女生数" from student group by grade;
select grade,count(
case
when sex=1 then 1
--else null
end
) "男生数",count(
case
when sex = 2 then 1
--else null
end
) "女生数" from student group by grade;