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