SELECT SALES_DT
, LISTAGG(PRODUCT_NM, ',') WITHIN GROUP (ORDER BY PRODUCT_NM) AS ITEMS
FROM TB_SALES
GROUP BY SALES_DT;
LISTAGG에는 중복제거 DISTINCT 사용불가로, 중복값이 조회된다
SELECT DISTINCT SALES_DT
, LISTAGG(PRODUCT_NM, ',') WITHIN GROUP (ORDER BY PRODUCT_NM)
OVER(PARTITION BY SALES_DT) AS PRODUCT_NM
FROM TB_SALES;
SELECT LISTAGG(PRODUCT_NM, ',') WITHIN GROUP (ORDER BY PRODUCT_NM) AS ITEMS
FROM (select DISTINCT PRODUCT_NM from TB_SALES);
'스터디 > Oracle' 카테고리의 다른 글
[오라클/Oracle] INSTER, SUBSTR, REPLACE (0) | 2021.09.18 |
---|---|
[Oracle/오라클] 다중 LIKE 조건 REGEXP_LIKE (0) | 2021.07.17 |
[Oracle/오라클] ROLLUP 소계 / 총계 표현하기 (0) | 2021.07.16 |
[Oracle/오라클] ADD_MONTHS, MONTH_BETWEEN (0) | 2021.07.11 |
[Oracle/오라클] LAST_DAY 월의 마지막 날 구하기 (0) | 2021.07.11 |