CUME_DIST:-
=============
此功能计算的是分配的行数少于或等于的行数少于或等于行数的比率。
PERCENT_RANK:此函数使用公式计算行的分配比例与分区中行数的比例
(RRP-1)/(NRP-1)
分区的RRP等级。
NRP-行的分区数。
这两个功能都将DENSE_RANK用于其排名,并且可以指定为升序或降序。
示例示例1
----------------------------------
SELECT DEPTNO,EMPNO,SUM(SAL) SALARY,
CUME_DIST() OVER(ORDER BY SUM(SAL)DESC)CUM_SAL,
PERCENT_RANK() OVER (ORDER BY SUM(SAL)DESC)PER_SAL
FROM EMP
GROUP BY DEPTNO,EMPNO
ORDER BY SALARY DESC;
示例2
----------------------------------
SELECT EMPNO,SUM(SAL) SALARY,
RANK() OVER(ORDER BY SUM(SAL) DESC) RANK,
DENSE_RANK() OVER(ORDER BY SUM(SAL) DESC)DENSE_RANK,
CUME_DIST() OVER(ORDER BY SUM(SAL)DESC)CUM_SAL,
PERCENT_RANK() OVER (ORDER BY SUM(SAL)DESC)PER_SAL
FROM EMP
GROUP BY EMPNO
ORDER BY RANK;
示例示例3
-----------------------------------
员工薪水3000的排名。
-------------------------------------------------- ----------------------------------------
SELECT
RANK(3000) WITHIN GROUP
(ORDER BY SUM(SAL) DESC) HYP_RANK,
DENSE_RANK(3000) WITHIN GROUP
(ORDER BY SUM(SAL) DESC) HYP_D_RANK,
CUME_DIST(3000) WITHIN GROUP
(ORDER BY SUM(SAL) DESC) HYP_CUM_RANK,
PERCENT_RANK(3000) WITHIN GROUP
(ORDER BY SUM(SAL) DESC ) HYP_PER_RANK
FROM EMP
GROUP BY EMPNO;
“ WITHIN GROUP”条款具有在确定排名之前将虚构行注入结果集中的作用。
From: https://bytes.com/topic/oracle/insights/671959-cume_dist-function