通过sqlsever中的case语句来查询各个学院的男生女生人数
时间: 2023-05-18 10:03:03 浏览: 492
可以使用以下 SQL 语句查询各个学院的男生女生人数:
SELECT
学院,
SUM(CASE WHEN 性别 = '男' THEN 1 ELSE 0 END) AS 男生人数,
SUM(CASE WHEN 性别 = '女' THEN 1 ELSE 0 END) AS 女生人数
FROM
学生表
GROUP BY
学院
相关问题
请用sqlsever具体语句帮我查询每系学生人数
Sure, here's the SQL query to get the number of students in each department:
SELECT department, COUNT(*) as total_students
FROM students
GROUP BY department;
This will give you a result set with two columns: the name of each department and the total number of students in that department.
请用sqlsever语句帮我查询每系学生人数
Sure, here's the SQL Server statement to help you query the number of students in each department:
SELECT Department, COUNT(*) as StudentCount
FROM Students
GROUP BY Department