SELECT T.CD, SUBSTR(MAX(SYS_CONNECT_BY_PATH( T.NM, ',')), 2) FROM ( SELECT CD, NM, ROWNUM AS RNUM FROM ( SELECT 'A' CD, 1 NM FROM DUAL UNION ALL SELECT 'A' CD, 2 NM FROM DUAL UNION ALL SELECT 'A' CD, 3 NM FROM DUAL)) T GROUP BY T.CD START WITH RNUM = 1 CONNECT BY PRIOR RNUM = RNUM - 1 위 내용을 응용하면 아래와 같이 표현될 수 있다. SELECT SUBSTR(MAX(SYS_CONNECT_BY_PATH( PLACE_NM, ',')), 2) FROM ( SELECT PLACE_NM, ROWNUM AS RNUM FROM ( SELECT A.PLACE_NM FROM MO_PTR_PLACE A, MO_PTR_COURSE_PLACE B WHERE B.PS_CD = A.PS_CD AND B.PLACE_SEQ = A.PLACE_SEQ AND B.PS_CD = '1001' ORDER BY B.ORDER_SEQ ) ) T START WITH RNUM = 1 CONNECT BY PRIOR RNUM = RNUM - 1 |
2011년 5월 18일 수요일
[Oracle] 세로결과를 가로로 바꾸기
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기