Skip to content

Instantly share code, notes, and snippets.

@Chetan496
Created October 21, 2016 09:48
Show Gist options
  • Save Chetan496/526792c5dc58cf1691a5357676ed9c96 to your computer and use it in GitHub Desktop.
Save Chetan496/526792c5dc58cf1691a5357676ed9c96 to your computer and use it in GitHub Desktop.
LISTAGG in Oracle
SELECT deptno, LISTAGG(ename, ',') WITHIN GROUP (ORDER BY ename) AS employees
FROM emp
GROUP BY deptno;
Using the WM_CONCAT function:
SELECT deptno, wm_concat(ename) AS employees
FROM emp
GROUP BY deptno;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment