56,677
社区成员
发帖
与我相关
我的任务
分享
select c.pid,t1.flag1,t1.flag2,t2.opantion1
from c left join (
select pid,
sum(if(flag=1,1,0)) as flag1 ,
sum(if(flag=2,1,0)) as flag2
from a where flag=1 or flag=2 group by pid
) t1 on c.pid=t1.pid
left join (select pid,count(*) as opantion1 from b where opention=1 group by pid) t2
on c.pid=t2.pid