2012년 10월 9일 화요일

트리구조 종합




   SELECT SYS_CONNECT_BY_PATH (LEVEL, '/') PATH,
          LEVEL,
          MENU_ID,
          UP_MENU_ID,
          RN,
          CNT,
          MENU_NM_KO
     FROM (SELECT MENU_ID,
                  UP_MENU_ID,
                  MENU_NM_KO,
                  MENU_URL,
                  MENU_SN,
                  ROW_NUMBER () OVER (PARTITION BY UP_MENU_ID ORDER BY MENU_SN ASC) RN,
                  COUNT (*) OVER (PARTITION BY UP_MENU_ID) CNT
             FROM TB_MENU
            WHERE USE_YN = 'Y') A
    WHERE 1 = 1
CONNECT BY PRIOR A.MENU_ID = A.UP_MENU_ID
START WITH A.UP_MENU_ID = 'root'
ORDER SIBLINGS BY A.MENU_SN ASC

댓글 없음:

댓글 쓰기