1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
SQL> SELECT DEPTNO,EMPNO,ENAME,SAL,MGR,LEVEL,CONNECT_BY_ISLEAF FEUILLE
2 FROM EMP
3 CONNECT BY PRIOR EMPNO=MGR
4 START WITH MGR IS NULL
5 ORDER BY LEVEL;
DEPTNO EMPNO ENAME SAL MGR LEVEL FEUILLE
---------- ---------- ---------- ---------- ---------- ---------- ----------
10 7839 KING 5000 1 0
20 7566 JONES 2975 7839 2 0
30 7698 BLAKE 2850 7839 2 0
10 7782 CLARK 2450 7839 2 0
20 7902 FORD 3000 7566 3 0
30 7521 WARD 1250 7698 3 1
30 7900 JAMES 950 7698 3 1
10 7934 MILLER 1300 7782 3 1
30 7499 ALLEN 1600 7698 3 1
20 7788 SCOTT 3000 7566 3 0
30 7654 MARTIN 1250 7698 3 1
DEPTNO EMPNO ENAME SAL MGR LEVEL FEUILLE
---------- ---------- ---------- ---------- ---------- ---------- ----------
30 7844 TURNER 1500 7698 3 1
20 7876 ADAMS 1100 7788 4 1
20 7369 SMITH 800 7902 4 1
14 rows selected.
SQL> SELECT DEPTNO,EMPNO,ENAME,SAL,MGR,LEVEL,CONNECT_BY_ISLEAF FEUILLE
2 FROM EMP
3 WHERE CONNECT_BY_ISLEAF =1
4 CONNECT BY PRIOR EMPNO=MGR
5 START WITH MGR IS NULL
6 ORDER BY level;
DEPTNO EMPNO ENAME SAL MGR LEVEL FEUILLE
---------- ---------- ---------- ---------- ---------- ---------- ----------
30 7521 WARD 1250 7698 3 1
30 7900 JAMES 950 7698 3 1
30 7499 ALLEN 1600 7698 3 1
10 7934 MILLER 1300 7782 3 1
30 7654 MARTIN 1250 7698 3 1
30 7844 TURNER 1500 7698 3 1
20 7369 SMITH 800 7902 4 1
20 7876 ADAMS 1100 7788 4 1
8 rows selected.
SQL> |
Partager