Monday, October 25, 2010

Oracle 11g-Listagg - Merge Rows into Single Columns

The LISTAGG analytic function was introduced in Oracle 11g Release 2, making it very easy to aggregate strings.

Sample Sql: 

select listagg(''''||NAME||'''',',') within group (order by NAME) from PS_PERSON 

I/P
---
Name
------
A
B
C
D
E

The Output as
-----------------
'A','B','C','D','E'


:-)

No comments: