2012년 10월 22일 월요일

connect by




SELECT  LEVEL depth,
       a.tree_id,
       a.tree_text,
       a.parent_tree_id,
       a.view_ord,
       DECODE(CONNECT_BY_ISLEAF, 1, 'true', 'false') as leaf,
       SUBSTR(SYS_CONNECT_BY_PATH(a.tree_text, ' > '),4) full_name,
       SUBSTR(SYS_CONNECT_BY_PATH(a.tree_id, '|'),2) full_code
 FROM TB_SAMPLE_TREE a
 START WITH a.PARENT_TREE_ID IS NULL
 CONNECT BY PRIOR a.TREE_ID = a.PARENT_TREE_ID
 ORDER SIBLINGS BY a.view_ord

댓글 없음:

댓글 쓰기