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‘)),2) as 环比 from temp t order by month asc (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |