用上面的数据,编写SQL语句,查询每个班级学生的男生人数、女生人数
时间: 2024-05-20 19:16:38 浏览: 95
SQL语句,统计出班级的男女人数
SELECT class,
SUM(CASE WHEN gender = '男' THEN 1 ELSE 0 END) AS male_count,
SUM(CASE WHEN gender = '女' THEN 1 ELSE 0 END) AS female_count
FROM student
GROUP BY class;
阅读全文