----补充同期的三种算法
--总评得分同期
create or replace view bi_pm_nw_sw_dqdfqk_fyn_zpdf_tq as
select
to_char(nd) nd,
to_char(jd) jd,
sq,
ddmc,
zpdf,
first_value(zpdf) over(partition by ddmc order by to_date(nd || '-' || jd, 'yyyy-mm') range between NUMTOYMINTERVAL(1, 'year') PRECEDING and NUMTOYMINTERVAL(1, 'year') PRECEDING) zpdf_tq
from PM_NW_SW_DQDFQK where sq<>'云南'
union all
select --这里只针对所有区域单位的最大季度补充
to_char(nd+1) nd,
to_char(jd) jd,
sq,
ddmc,
null zpdf,
zpdf zpdf_tq
from PM_NW_SW_DQDFQK
where sq<>'云南' and nd = to_char(sysdate - NUMTOYMINTERVAL(1, 'year'), 'yyyy')
and jd>(select max(jd) from PM_NW_SW_DQDFQK where sq<>'云南' and nd=to_char(sysdate, 'yyyy'));
--总评分同期第二种算法 可以补充所有的同期数据 但是数据多时速度会慢 推荐用法
create or replace view bi_pm_nw_sw_dqdfqk_fyn_zpdf_tq as
select to_char(nd) nd,
to_char(jd) jd,
sq,
ddmc,
zpdf,
first_value(zpdf) over(partition by ddmc order by to_date(nd || '-' || jd, 'yyyy-mm') range between NUMTOYMINTERVAL(1, 'year') PRECEDING and NUMTOYMINTERVAL(1, 'year') PRECEDING) zpdf_tq
from PM_NW_SW_DQDFQK
where sq <> '云南'
union all
select *
from (select to_char(nd + 1) nd,
to_char(jd) jd,
sq,
ddmc,
null zpdf,
zpdf zpdf_tq
from PM_NW_SW_DQDFQK
where sq <> '云南')
where (nd, jd, sq, ddmc) not in
(select nd, jd, sq, ddmc from PM_NW_SW_DQDFQK where sq <> '云南')
and to_number(nd) <= to_number(to_char(sysdate, 'yyyy'));
--总评分同期第三种算法 可以补充所有的同期数据 但是数据多时速度会慢很多
create or replace view bi_pm_nw_sw_dqdfqk_fyn_zpdf_tq as
select nd, jd, sq, ddmc, zpdf, zpdf_tq
from (select decode(a.nd, null, b.nd, a.nd) nd,
decode(a.jd, null, b.jd, a.jd) jd,
decode(a.sq, null, b.sq, a.sq) sq,
decode(a.ddmc, null, b.ddmc, a.ddmc) ddmc,
a.zpdf,
b.zpdf_tq
from (select --当前数据
to_char(nd) nd, to_char(jd) jd, sq, ddmc, zpdf
from PM_NW_SW_DQDFQK
where sq <> '云南') a
full outer join (select --上年数据
to_char(nd + 1) nd,
to_char(jd) jd,
sq,
ddmc,
zpdf zpdf_tq
from PM_NW_SW_DQDFQK
where sq <> '云南') b
on a.nd = b.nd
and a.jd = b.jd
and a.sq = b.sq
and a.ddmc = b.ddmc
order by nd, jd)
where to_number(nd) <= to_number(to_char(sysdate, 'yyyy'));
分享到:
相关推荐
oracle补充oracle补充oracle补充oracle补充
oracle补充! 值得下载看看!资源免费,大家分享!!
ORACLE补充了ORACLE常用的表空间,系统表等方便管理和操作
Oracle基础运用知识,包括如何创建表、修改表、拷贝表等
oracle资料oracle资料oracle资料oracle资料oracle资料oracle资料oracle资料oracle资料oracle资料oracle资料oracle资料oracle资料
Oracle详解Oracle详解Oracle详解Oracle详解
oracle 数据库oracle 数据库oracle 数据库oracle 数据库oracle 数据库oracle 数据库oracle 数据库
Oracle 9i Client (Oracle 9i 客户端) 简化版 (不安装Oracle客户端,也可以使用PLSQL Developer 不用安装Oracle客户端也可以使用PLSQL Developer 绿色! 安全! 轻便! 可靠! 1、本软件可作为简单的Oracle9i客户端...
oracle_课件oracle_课件oracle_课件oracle_课件oracle_课件oracle_课件oracle_课件oracle_课件oracle_课件oracle_课件oracle_课件
ORACLE数据库ORACLE数据库ORACLE数据库ORACLE数据库ORACLE数据库ORACLE数据库ORACLE数据库ORACLE数据库
Dbmover for Mysql to Oracle 是高效的将Mysql导入到Oracle数据库的工具。 使用DBMover可以灵活定义Mysql和Oracle之间表和字段的对照关系,也可以在DBMover创建一个查询,把查询结果当作源表转入到Oracle中。 ...
Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典Oracle宝典...
ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区
python-oracledb的源码和使用示例代码, python-oracledb 1.0,适用于Python versions 3.6 through 3.10. Oracle Database; This directory contains samples for python-oracledb. 1. The schemas and SQL ...
全书共分5部分:初始化环境、加载数据、保护数据、传输数据和基础补充。 《涂抹Oracle:三思笔记之一步一步学Oracle》语言生动幽默,案例丰富,实践性强,在章节编排和内容组织方面,主要面向初次接触Oracle数据库...
oracle 闪回oracle 闪回oracle 闪回oracle 闪回oracle 闪回oracle 闪回oracle 闪回oracle 闪回oracle 闪回oracle 闪回oracle 闪回oracle 闪回oracle 闪回oracle 闪回
oracle 9i所有版本最新下载链接 直接迅雷下载 Oracle9i Database Release 2 Enterprise/Standard/Personal Edition for Windows NT/2000/XP ...
oracle脚本oracle脚本oracle脚本oracle脚本oracle脚本
Oracle资料 Oracle九阴真经 Oracle函数大全 Oracle错误码 Oracle参考手册 Oracle全套chm.7z
使用了,ODP.NET 方式链接数据库,只要把Oracle.ManagedDataAccess.dll引入取代以前的Oracle.DataAccess.dll即可。 这种方式也是oracle公司提供的,稳定性要比之前那种更好,而且也是免安装客户端的,目前还没测试...