大家帮忙看看这条sql语句,它的意思是想得到一个增长比例,我写的比较长,看能不能给优化一下啊,谢谢了!
select aa.ss / decode(bb.comm,0,1,bb.comm)
from (select a.balanc_id,
a.balanc_desc,
b.area_no area_id,
nvl(month_id, 'null') month_id,
(cnt_balance_income - cnt_balance_payout) ss from dmcode.dmcode_balance_type a, dm_test.dm_kkpi_m_balance b
where a.balanc_id = b.balanc_id and month_id >= '200601' and
month_id <= '200712') aa,
(select balanc_id, sum(cnt_balance_income - cnt_balance_payout) comm
from dm_test.dm_kkpi_m_balance
group by balanc_id) bb
where aa.balanc_id = bb.balanc_id ;
select aa.ss / decode(bb.comm,0,1,bb.comm)
from (select a.balanc_id,
a.balanc_desc,
b.area_no area_id,
nvl(month_id, 'null') month_id,
(cnt_balance_income - cnt_balance_payout) ss from dmcode.dmcode_balance_type a, dm_test.dm_kkpi_m_balance b
where a.balanc_id = b.balanc_id and month_id >= '200601' and
month_id <= '200712') aa,
(select balanc_id, sum(cnt_balance_income - cnt_balance_payout) comm
from dm_test.dm_kkpi_m_balance
group by balanc_id) bb
where aa.balanc_id = bb.balanc_id ;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货