select
EmpDepID,
count(1) as 总人数,
count(case when EmpSex = 300 then 1 end ) as 男生数,
count(case when EmpSex = 301 then 1 end ) as 女生数
from dbo.tbEmployee
group by EmpDepID
select count 多条统计
最新推荐文章于 2022-12-01 08:00:00 发布
select
EmpDepID,
count(1) as 总人数,
count(case when EmpSex = 300 then 1 end ) as 男生数,
count(case when EmpSex = 301 then 1 end ) as 女生数
from dbo.tbEmployee
group by EmpDepID