函数row_number() over(partition by~~order by ~~ desc)的用法

select tbexamineegrade.*,
   row_number() over(partition by userid,TpID order by exscore desc) lev

--------------------------------------------------
:查询员工的工资,按部门排序

select ename,sal,row_number() over (partition by deptno order by sal desc) as sal_order from scott.emp;

执行结果:

ENAME                           SAL      SAL_ORDER
-------------------- ---------- ----------
KING                           5000              1
CLARK                          2450              2
MILLER                         1300              3
SCOTT                          3000              1
FORD                           3000              2
JONES                          2975              3
ADAMS                          1100              4
SMITH                           800              5
BLAKE                          2850              1
ALLEN                          1600              2
TURNER                         1500              3
WARD                           1250              4
MARTIN                         1250              5
JAMES                           950              6
----------------------------------------------------------
按部门进行分组 然后再每组内部进行排序 就是对整个结果集而言的

你可能感兴趣的:(oracle)