Listagg

Listagg

LISTAGG orders data within each group specified in the ORDER BY clause and then concatenates the values of the measure column.

Syntax:

LISTAGG (measure_expression [, ‘delimiter’])
WITHIN GROUP (order_by_clause) [OVER (query_partition_clause)]

Example:

SELECT LISTAGG(e.ENAME, '; ') WITHIN GROUP (ORDER BY e.ENAME)
FROM EMP e
WHERE e.DEPTNO=10;

Output:

CLARK; KING; MILLER