It's Repository

blog.selpa.co.kr

포토로그



[오라클] 계층쿼리 최상단 부모키 oracle/mysql

       SELECT DECODE (
                 INSTR (SYS_CONNECT_BY_PATH (C.stratum_id, '|'), '|', 2),
                 0, stratum_id,
                 SUBSTR (
                    SYS_CONNECT_BY_PATH (C.stratum_id, '|'),
                    2,
                    INSTR (SYS_CONNECT_BY_PATH (C.stratum_id, '|'), '|', 2) - 2))
                 AS theme_coloc,
              SUBSTR (SYS_CONNECT_BY_PATH (C.stratum_id, '|'), 2)
                 AS theme_path_cd,
              STRATUM_ID,
              STRATUM_PARENT,
         FROM theme_stratum C
   START WITH C.stratum_parent = '0' AND C.stratum_lv = '1'
   CONNECT BY PRIOR C.stratum_id = C.stratum_parent

덧글

댓글 입력 영역