Sql server题:按性别分组统计学生表中男女同学的人数,用t_sql语句表示

2025-03-24 06:57:40
推荐回答(2个)
回答1:

select

nv=(select count(*) from table where sex='女'),
nan=(select count(*) from table where sex='男')
from table
这样就可以分别统计男和女的数量了.

回答2:

select sex , count(*) 人数 from table group by sex