rinkubhat
New User
Joined: 13 Sep 2005 Posts: 35 Location: India
|
|
|
|
I Have table with two columns Employee Name and Age
I want to display all the employee names for a particular age in 1 row.
Table
Employee Name Age
ABC 20
XYZ 20
ERP 40
TRQ 40
AST 20
Result should be
Employee Age
ABC,XYZ,AST 20
ERP,TRQ 40
How can this be done in DB2 |
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
by using google or forum search keywords "Concatenating rows in DB2"
Code: |
select , replace(replace(cast(xml2clob(xmlagg(xmlelement(name X ,emp))) as varchar(200) ),'<X>','') ,'</X>',' ')
, age
from tab1
group by age |
|
|