select sClass 班级,count(*) 班级学生总人数,
sum(case when sGender=0 then 1 else 0 end) 该班级女生人数,
sum(case when sGender=0 then 1 else 0 end)1.0/count() 该班级女生所占比例,
sum(case when sGender=1 then 1 else 0 end) 该班级男生人数,
sum(case when sGender=1 then 1 else 0 end)1.0 /count() 该班级男生所占比例
from student GROUP BY sClass ORDER BY sClass asc

Logo

更多推荐