日期:2014-05-17 浏览次数:20873 次
SQL> select deptno,ename,sal from emp order by deptno,sal desc;
DEPTNO ENAME SAL
---------- ---------- ----------
10 KING 5000
10 CLARK 2450
10 MILLER 1300
20 SCOTT 3000
20 FORD 3000
20 JONES 2975
20 ADAMS 1100
20 SMITH 800
30 BLAKE 2850
30 ALLEN 1600
30 TURNER 1500
DEPTNO ENAME SAL
---------- ---------- ----------
30 MARTIN 1250
30 WARD 1250
30 JAMES 950
已选择14行。
SQL> break on deptno skip 1
SQL> select deptno,ename,sal from emp order by deptno,sal desc;
DEPTNO ENAME SAL
---------- ---------- ----------
10 KING 5000
CLARK 2450
MILLER 1300
20 SCOTT 3000
FORD 3000
JONES 2975
ADAMS 1100
SMITH 800
30 BLAKE 2850
DEPTNO ENAME SAL
---------- ---------- ----------
30 ALLEN 1600
TURNER 1500
MARTIN 1250
WARD 1250
JAMES 950
已选择14行。
SQL> break on ''
SQL>
--查出各部门薪水前三名的员工姓名、薪水。
SQL> select * from(
2 select deptno,rank() over(partition by deptno order by sal desc) rk,ename,sal
3 from emp
4 )
5 where rk <=3
6 /
DEPTNO&