본문 바로가기

빅데이터과정/SQL

#43_140812_계층적질의문

728x90


# 계층적질의문



 

  • 계층적질의문(SYS_CONNECT_BY_PATH)

  

순방향

SELECT ename, SYS_CONNECT_BY_PATH(ENAME||'('||sal||')','/') employee

FROM EMP

START WITH ename='KING'

CONNECT BY PRIOR EMPNO = MGR

 


 

SELECT ename, LEVEL, LPAD(' ', 2*LEVEL)||SYS_CONNECT_BY_PATH(ENAME,'/') PATH

  FROM EMP

 START WITH ename='KING'

CONNECT BY PRIOR EMPNO = MGR;

 




역방향

SELECT ename, LEVEL, SYS_CONNECT_BY_PATH(ENAME||'('||sal||')','/') employee

FROM EMP

START WITH ename='ADAMS'

CONNECT BY EMPNO = PRIOR MGR;

 


 

 














'빅데이터과정 > SQL ' 카테고리의 다른 글

#8_140624_정규식 함수  (0) 2014.07.14
#8_140624_with  (0) 2014.07.14
#7_140623_DCL(Data Control Language)  (0) 2014.07.14
#7_140623_CORRELATED SUBQUERY  (0) 2014.07.14
#7_140623_마지막 문제  (0) 2014.07.14