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

猜你喜欢

转载自wuhongbo.iteye.com/blog/1870331