500w数据
耗时10s 只遍历一次。
sum( if(a.DEBT_TYPE = 0, LOANEE_AMOUNT, 0)) as 'CZ'
sum( if(a.DEBT_TYPE = 1,LOANEE_AMOUNT, 0 )) as'EJZ'
一次遍历耗时9.9s
三次遍历,耗时30s
select DEBT_TYPE , count(*) , sum(LOANEE_AMOUNT)
from t_zg_loanee_apply
where DELETE_STATUS=0
group by DEBT_TYPE
两次遍历,耗时22s
对mysql压力未知。对性能要求不高且为了不分mysql大量资源。。。组长让我用简单sql。
ps:group by 等的使用技巧
http://www.cnblogs.com/allensun-193/p/5897925.html