아래와 같은 오라클 쿼리인데 이걸 PostgreSQl WITH RECURSIVE로 변경해야 하는데 어떻게 하는지 전혀 모르겠습니다.
어떻게 하면 될런지요?
SELECT a. C_CODE
, a. C_NAME, a. UP_C_CODE, a.DESC, a. DEPT_LEVEL
, substr(sys_connect_by_path(c_name, '>'), 4) as F_PATH
FROM C_MGT a
WHERE (DEL_YN IS NULL OR DE_YN != '1')
AND C_TYPE = 'ABC'
AND SUB_CODE = 'GGGGG'
AND connect_by_isleaf = 1
START WITH F_TYPE = 'PP01'
CONNECT BY PRIOR C_CODE = UP_C_CODE
AND (DEL_YN is null or DEL_YN != '1')
ORDER SIBLINGS BY to_number(DEPT_SEQ)
>> PostgreSQL로
|