https://oracle-base.com/articles/misc/string-aggregation-techniques
LISTAGG Analytic Function in 11g Release 2
The LISTAGG
analytic function was introduced in Oracle 11g Release 2, making it very easy to aggregate strings. The nice thing about this function is it also allows us to order the elements in the concatenated list. If you are using 11g Release 2 you should use this function for string aggregation.
COLUMN employees FORMAT A50 SELECT deptno, LISTAGG(ename, ',') WITHIN GROUP (ORDER BY ename) AS employees FROM emp GROUP BY deptno; DEPTNO EMPLOYEES ---------- -------------------------------------------------- 10 CLARK,KING,MILLER 20 ADAMS,FORD,JONES,SCOTT,SMITH 30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD 3 rows selected.
'Database' 카테고리의 다른 글
ORACLE SYSTEM 계정 비밀번호 분실시 해결방법 (0) | 2017.02.06 |
---|---|
(Oracle) 오라클 버전 확인 (0) | 2016.11.30 |
(Oracle) Deterministic Function의 비밀 (0) | 2016.09.30 |
오라클 임시 테이블 with ... as (0) | 2016.07.29 |
CTAS (Create Table as select ) 시타스 (0) | 2016.07.13 |