排序函数-分区范围-Oracle分析函数
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了排序函数-分区范围-Oracle分析函数相关的知识,希望对你有一定的参考价值。
ROW_NUMBER() -Partition (group by) the expression values and assigns integer values to the rows depending on their order.
thx to Shouvik Basu < http://www.orafaq.com/node/55 >
-- Example 1 ROW_NUMBER () OVER (PARTITION BY A.LN ORDER BY A.FC_SET_UP_DT DESC) AS MAX_SEQ_NO -- Example 2 /* ROW_NUMBER( ) gives a running serial number to a partition of records. It is very useful in reporting, especially in places where different partitions have their own serial numbers. In Query-5, the function ROW_NUMBER( ) is used to give separate sets of running serial to employees of departments 10 and 20 based on their HIREDATE. */ SELECT empno, deptno, hiredate, ROW_NUMBER( ) OVER (PARTITION BY deptno ORDER BY hiredate NULLS LAST) SRLNO FROM emp WHERE deptno IN (10, 20) ORDER BY deptno, SRLNO; EMPNO DEPTNO HIREDATE SRLNO ------ ------- --------- ---------- 7782 10 09-JUN-81 1 7839 10 17-NOV-81 2 7934 10 23-JAN-82 3 7369 20 17-DEC-80 1 7566 20 02-APR-81 2 7902 20 03-DEC-81 3 7788 20 09-DEC-82 4 7876 20 12-JAN-83 5 8 ROWS selected.
以上是关于排序函数-分区范围-Oracle分析函数的主要内容,如果未能解决你的问题,请参考以下文章