col level format 999
col empno format a20
col path format a30
select level, lpad(empno, level*4, ' ') as empno, ename, job, mgr, sal
, sys_connect_by_path(ename, '/') as path
from emp e
start with empno = 7839
connect by prior empno = mgr
order siblings by sal;
select level, lpad(empno, level*4, ' ') as empno, ename, job, mgr, sal
, sys_connect_by_path(ename, '/') as path
from emp e
where empno = 7369
start with empno = 7839
connect by prior empno = mgr
order siblings by sal;
'Oracle > SQL Fundamentals II' 카테고리의 다른 글
15일차 # 8 Regular Expression (정규표현식) (0) | 2012.04.24 |
---|---|
15일차 # 추가 (0) | 2012.04.24 |
15일차 # 정렬: Order siblings by (0) | 2012.04.24 |
15일차 # 7-13: Eliminating Nodes or Branches (0) | 2012.04.24 |
15일차 # 7-11: 결과를 보기 좋게 만들기 (0) | 2012.04.24 |