row 값을 column으로 바꿔주는 예제.

Posted by MD워시퍼
2008. 11. 26. 11:47 Site & Infomation
728x90
SELECT SUBSTR (MAX (SYS_CONNECT_BY_PATH (nvl(JOB_TASK_CD,'(RESULT)'), '/ ') ), 2) argument_names 
           FROM (SELECT F_FRM_CODE_NM_C('01','JOB_TASK_CD', TASK.JOB_TASK_CD, TASK.STA_YMD, '1') AS JOB_TASK_CD,
                        JOB_HIS_DET_ID,  
                        ROW_NUMBER() OVER (PARTITION BY JOB_HIS_DET_ID ORDER BY JOB_HIS_DET_ID) RUNM
                   FROM JOH_JOB_HIS_TASK TASK)
          WHERE JOB_HIS_DET_ID = DET.JOB_HIS_DET_ID
          START WITH RUNM = 1
          CONNECT BY PRIOR RUNM = RUNM -1 AND PRIOR JOB_HIS_DET_ID = JOB_HIS_DET_ID
          GROUP BY JOB_HIS_DET_ID