select 部门ID,count(case when 客户状态=0 then 1 else 0 end) ,
count(case when 客户状态=1 then 1 else 0 end),
count(case when 客户状态=2 then 1 else 0 end)
from 客户信息表 group by 部门ID
count(case when 客户状态=1 then 1 else 0 end),
count(case when 客户状态=2 then 1 else 0 end)
from 客户信息表 group by 部门ID
大侠,我真么用啊?怎么才能取到count 的值啊????
谢谢大侠!
select 部门ID,客户状态,count(客户状态)
from 客户信息表
group by 部门ID,客户状态