DB2 SQL: Grouping records with same id in result? -
if have table 2 columns
text | id --------- aaa | 1 bbb | 1 eee | 1 mmm | 2 zzz | 2 ... is possible write query groups id , outputs following result:
id | text ------------------ 1 | aaa, bbb, eee 2 | mmm, zzz ... thanks!
give try,
select id, substr(xmlserialize(xmlagg(xmltext(concat( ', ',text))) varchar(1024)), 3) tablename group id;
Comments
Post a Comment