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

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -