Hi Everyone,
If there is a requirement to list values from multiple rows to a single row related with a specific value, Oracle string aggregation function can be used to achieve this. Below are the different methods available in different versions of Oracle.
LISTAGG Analystic Function in 11g
Release 2
SELECT DEPTNO, LISTAGG(ENAME, ',')
WITHIN GROUP (ORDER BY ENAME) AS EMPLOYEES
FROM EMP
GROUP BY DEPTNO;
WM_CONCAT Function (Works with 11g Release 1)
SELECT DEPTNO, WM_CONCAT(ENAME) AS EMPLOYEES
FROM EMP
GROUP BY DEPTNO;
Table Content
Result of the query
Thanks for visiting my blog and reading this article !
0 comments:
Post a Comment