分段统计数据

select fund_account,BrokerID,
sum(case when RulesID>1000000 AND RulesID<2000000 then 1 else 0 end ),
sum(case when RulesID>2000000 AND RulesID<3000000 then 1 else 0 end ),
sum(case when RulesID>3000000 AND RulesID<4000000 then 1 else 0 end ),
sum(case when RulesID>4000000 AND RulesID<5000000 then 1 else 0 end )
from investorrules where fund_account like '%1%' GROUP BY fund_account,BrokerID limit 1,21

原文地址:https://www.cnblogs.com/a9999/p/7826865.html