--가상 테이블
WITH TEST_TABLE AS (
SELECT '고구려' COUNTRY, '1대' ST, '동명성왕' KING_NM FROM DUAL UNION ALL
SELECT '고구려' COUNTRY, '3대' ST, '대무신왕' KING_NM FROM DUAL UNION ALL
SELECT '백제' COUNTRY, '1대' ST, '온조왕' KING_NM FROM DUAL UNION ALL
SELECT '고구려' COUNTRY, '2대' ST, '유리왕' KING_NM FROM DUAL UNION ALL
SELECT '백제' COUNTRY, '3대' ST, '기루왕' KING_NM FROM DUAL UNION ALL
SELECT '신라' COUNTRY, '2대' ST, '남해왕' KING_NM FROM DUAL UNION ALL
SELECT '신라' COUNTRY, '1대' ST, '박혁거세' KING_NM FROM DUAL UNION ALL
SELECT '백제' COUNTRY, '2대' ST, '다루왕' KING_NM FROM DUAL UNION ALL
SELECT '신라' COUNTRY, '3대' ST, '유리이사금' KING_NM FROM DUAL
)
--조회 쿼리
SELECT COUNTRY
, SUBSTR( XMLAGG( XMLELEMENT(COL ,',', KING_NM) ORDER BY ST).EXTRACT('//text()' ).GETSTRINGVAL() , 2) KING_NM
FROM TEST_TABLE
GROUP BY COUNTRY
'데이터베이스 > 오라클' 카테고리의 다른 글
All_tab_comments (0) | 2021.09.08 |
---|---|
오라클컬럼변경 (0) | 2021.09.08 |
오라클ROLE (0) | 2021.09.08 |
오라클 권한 주기 (0) | 2021.09.08 |
Db펌프 작업예상시간 (0) | 2021.09.08 |
댓글