Oracle – merge multiple records into single row
Written on 15 May 2014, 10:09am
Another post in the series ‘remember this SQL trick‘ 🙂
The within group
clause can be used to merge multiple records into a single row. In the classic emp
table with ename
and deptno
columns, the query is:
select
deptno,
listagg (ename, ',')
WITHIN GROUP
(ORDER BY ename) enames
FROM
emp
GROUP BY
deptno
The article below displays more ways of doing this, but the query above worked for me.
Oracle SQL: displaying multiple column values per row
Written by Dorin Moise (Published articles: 277)
- Likes (0)
-
Share
- Comments (0)