sum(if(((approve_result=4 and open_status is null) or (approve_result=3 and open_status is null) or open_status=1 or open_status=2 or open_status=4),1,0)) wp,
sum(if(approve_result is null and source= 4,1,0)) a_unagree,
sum(if(((approve_result=4 and open_status is null) or (approve_result=3 and open_status is null) or open_status=1 or open_status=2 or open_status=4) and source = 4,1,0)) a_wp,
sum(if(approve_result=2 and source = 4,1,0)) wa,
sum(if(approve_result=1,1,0)) pass,
sum(if(approve_result=1 and source=2,1,0)) z_pass,
sum(if(approve_result=1 and source = 4,1,0)) a_pass,
sum(if(approve_result=0,1,0)) not_pass,
sum(if(source=4,1,0)) quick_pass
sum(if(((scc.approve_result=4 and scc.open_status is null) or (scc.approve_result=3 and scc.open_status is null) or scc.open_status=1 or scc.open_status=2 or scc.open_status=4),1,0)) wp,
sum(if(scc.approve_result is null and scc.source= 4,1,0)) a_unagree,
sum(if(((scc.approve_result=4 and scc.open_status is null) or (scc.approve_result=3 and scc.open_status is null) or scc.open_status=1 or scc.open_status=2 or scc.open_status=4) and scc.source = 4,1,0)) a_wp,
sum(if(scc.approve_result=2 and scc.source = 4,1,0)) wa,
sum(if(scc.approve_result=1,1,0)) pass,
sum(if(scc.approve_result=1 and scc.source=2,1,0)) z_pass,
sum(if(scc.approve_result=1 and scc.source = 4,1,0)) a_pass,
sum(if(scc.approve_result=0,1,0)) not_pass,
sum(if(scc.source=4,1,0)) quick_pass
<iftest="tempSubMchId">
,sum(if(locate(sub_merchant_id,#{tempSubMchId})>0 and skip_clearing=0,1,0)) temp_submchid
</if>
FROM sys_clients where is_valid = 1
FROM sys_clients c
left join sys_client_config scc on scc.client_id = c.client_id