oracle同環比計算


with temp as
(select to_char(jsrq , 'yyyymm') as month, sum(zfy ) as num
from hip_mz_ys a, JCXX_JG b, jcxx_ks c, jcxx_ry d
where a.jg_id = b.yljgdm
and a.bm_id = c.ksid
and a.ry_id = d.ylryid
group by to_char(jsrq , 'yyyymm'))
select month,
round(nvl(num * 100 / (select num
from temp t1
where t1.month = (substr(t.month, 1, 4) - 1) ||
substr(t.month, -2)),
0),
2) as 同比,
round(nvl(num * 100 /
(select num
from temp t2
where t2.month =
to_char(to_date(t.month, 'yyyymm') - 1, 'yyyymm')),
0),
2) as 環比
from temp t
order by month asc


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM