select count 多条统计

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章