淘先锋技术网

首页 1 2 3 4 5 6 7

临时记录:

查询每个部门工资前2名的员工(ename   sal   dname )

SELECT  ENAME ,SAL , DNAME FROM

  DEPT , (SELECT   ENAME ,SAL ,DEPTNO , ROW_NUMBER() OVER ( PARTITION BY DEPTNO ORDER BY SAL DESC)  R  from  EMP ) T

  WHERE T.DEPTNO = DEPT.DEPTNO AND T.R <= 2 ;

转载于:https://www.cnblogs.com/xqzblog/archive/2012/12/25/orc.html