阅读背景:

求总数case when

来源:互联网 
select agent_id, count(1) as zbs,sum(je) as zje from (

select agent_id,
sum(case when sjje < 2000 and fxzt = 0 then sjje 
     when sjje < 2000 and fxzt = 1005 then -1*sjje end) je    
from t_payfee_power where result_code = 0 and fxzt in (0,1005)

) a group by a.agent_id
select agent_id, count(1) as zbs,sum(je) as zje 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: