sql 查询多项不同统计

select
count(1) as all_total,
count(c1.id) as qq_total,
count(c2.id) as wx_total,
count(c3.id) as wx_hy_total

 

from t_customer c
left join t_customer c1 on c1.id=c.id and c1.come_from='1'
left join t_customer c2 on c2.id=c.id and c2.come_from='161'
left join t_customer c3 on c3.id=c.id and c3.come_from='161' and c3.visit_type=1

你可能感兴趣的:(sql)