oracle同环比计算

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

posted @ 2019-04-19 17:11 HoverChen 阅读( ...) 评论( ...) 编辑 收藏
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值