select MA001 as 供应商编号,MA003 as 供应商全称,sql
sum(case when TAC04>0 then 1 else 0 end)as 总笔数,--当字段大于0时则为1不然为0,全部值求和ide
sum(case when TAC01>0 then 1 else 0 end)AS 验收笔数,函数
sum(case when TA008>0 then 1 else 0 end) as 验退笔数spa
from QMSTA left join PURCC on CC001=TA001 AND CC002=TA002orm
LEFT JOIN PURMA ON CC005=MA001server
WHERE TA014='Y'blog
group by MA001,MA003图片
ORDER BY MA001,MA003get