Search This Blog

Monday, May 13, 2013

XMLAGG & listagg


XMLAGG  & listagg 

SELECT   dept,
         RTRIM (XMLAGG (XMLELEMENT (e, empname || ',')).EXTRACT ('//text()'),
                ','
               ) empnames
    FROM testingemp
GROUP BY dept

SELECT dept,listagg (empname, ',') WITHIN GROUP (ORDER BY empname)
        empnames
FROM testingemp
GROUP BY dept

SELECT  listagg (empname, ',') WITHIN GROUP (ORDER BY empname) employeenames
FROM testingemp

select rtrim (xmlagg (xmlelement (e, empname || ',')).extract ('//text()'), ',') Empnames
from testingemp