아래 쿼리는 idx가 2060 인 사람의 TCODE 개수만큼의
row로 결과가 나옵니다
이 것을 한개의 로우에 표현하려면 어떻게 쿼리를 수정하는지 궁금합니다
조언 부탁드립니다
select col01 from table01
where code01 = '107'
and code02 in (select TCODE from table02
where idx='2060');
현재결과
col01
-------
값1
값2
값3
원하는결과
col01
-------
값1, 값2, 값3
WITH t(type, name,code) AS ( SELECT 'A', '사과', '0' FROM dual UNION ALL SELECT 'A', '레몬', '1' FROM dual UNION ALL SELECT 'A', '포도', '2' FROM dual UNION ALL SELECT 'A', '참외', '3' FROM dual ) SELECT type , SUBSTR(XMLAgg(XMLElement(x, ',', name) ORDER BY code).Extract('//text()'), 2) name_9i , SUBSTR(XMLAgg(XMLElement(x, ',', code) ORDER BY code).Extract('//text()'), 2) code_9i , wm_concat(name) name_10g , wm_concat(code) code_10g , ListAgg(name, ',') WITHIN GROUP(ORDER BY code) name_11g , ListAgg(code, ',') WITHIN GROUP(ORDER BY code) code_11g FROM t GROUP BY type ;