首页 > 数据库 > Oracle > SQL OVER的作用和用法
例:
显示各部门员工薪金最高的前2名
SCOTT>select ename,sal from (select ename,row_number() over(partition by deptno
order by sal desc) no,sal from emp) where no<=2;
ENAME SAL
---------- ----------
KING 5000
CLARK 2450
SCOTT 3000
FORD 3000
BLAKE 2850
ALLEN 1600
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10685580/viewspace-1046450/ ,如需转载,请注明出处,否则将追究法律责任。