- 論壇徽章:
- 0
|
本帖最后由 oicq63236 于 2011-05-06 20:27 編輯
代碼如下,為何條件為負(fù)數(shù)時(shí),此語句執(zhí)行超慢,大約得20分鐘;而當(dāng)改為270(正數(shù))時(shí),檢索會(huì)在10秒以內(nèi)完成? 若做修改,該如何修改?
select count(*),sum(curSum.loanbalance)
from (select summ.customerid,sum(nvl(summ.loanbalance,0.0))/10000 as loanbalance
from cms_con_monthlybalancesummary summ
where substr(summ.organizationcode,1,6)=140605
and summ.year=2011 and summ.month=3
group by summ.customerid
having sum(nvl(summ.loanbalance,0.0))/10000>=-270) curSum
where
not exists(select summ.customerid,sum(nvl(summ.loanbalance,0.0))/10000 as loanbalance
from cms_con_monthlybalancesummary summ
where substr(summ.organizationcode,1,6)=140605
and summ.year=2010 and summ.month=12 and summ.customerid=curSum.customerid
group by summ.customerid
having sum(nvl(summ.loanbalance,0.0))/10000>=-270) |
|