我是靠谱客的博主 孝顺西牛,最近开发中收集的这篇文章主要介绍oracle中国如何实现同比,Oracle分析函数实现报表功能(同比,环比,累计,基比)...,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

CREATE TABLE salaryByMonth

(

employeeNo varchar2(20),

yearMonth varchar2(6),

salary number

) ;

insert into SALARYBYMONTH (EMPLOYEENO, YEARMONTH, SALARY)

values (1, '200805', 500);

insert into SALARYBYMONTH (EMPLOYEENO, YEARMONTH, SALARY)

values (1, '200802', 150);

insert into SALARYBYMONTH (EMPLOYEENO, YEARMONTH, SALARY)

values (1, '200803', 200);

insert into SALARYBYMONTH (EMPLOYEENO, YEARMONTH, SALARY)

values (1, '200804', 300);

insert into SALARYBYMONTH (EMPLOYEENO, YEARMONTH, SALARY)

values (1, '200708', 100);

commit;

SELECT EMPLOYEENO

,YEARMONTH

,SALARY

,MIN(SALARY) KEEP(DENSE_RANK FIRST ORDER BY YEARMONTH) OVER(PARTITION BY EMPLOYEENO) FIRST_SALARY -- 基比分析 salary/first_salary

,LAG(SALARY, 1, 0) OVER(PARTITION BY EMPLOYEENO ORDER BY YEARMONTH) AS PREV_SAL -- 环比分析,与上个月份进行比较

,LAG(SALARY, 12, 0) OVER(PARTITION BY EMPLOYEENO ORDER BY YEARMONTH) AS PREV_12_SAL -- 同比分析,与上个年度相同月份进行比较

,SUM(SALARY) OVER(PARTITION BY EMPLOYEENO, SUBSTR(YEARMONTH, 1, 4) ORDER BY YEARMONTH RANGE UNBOUNDED PRECEDING) LJ --累计值

FROM SALARYBYMONTH

ORDER BY EMPLOYEENO

,YEARMONTH

最后

以上就是孝顺西牛为你收集整理的oracle中国如何实现同比,Oracle分析函数实现报表功能(同比,环比,累计,基比)...的全部内容,希望文章能够帮你解决oracle中国如何实现同比,Oracle分析函数实现报表功能(同比,环比,累计,基比)...所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部