Skip to content

Instantly share code, notes, and snippets.

View timothymolter's full-sized avatar

Tim Molter timothymolter

View GitHub Profile
@timothymolter
timothymolter / gist:eda0907623524e5eb99b0e8b95e758a1
Last active November 20, 2017 20:37 — forked from zarkosusnjar/gist:1675843
Aggregate concatenation - returning grouped rows as delimited list in DB2, AS400
-- using db2 newer versions
create table t1 (num int, color varchar(10));
insert into t1 values (1,'red'), (1,'black'), (2,'red'), (2,'yellow'), (2,'green');
select num,
substr( xmlserialize( xmlagg( xmltext( concat( ', ', color ) ) ) as varchar( 1024 ) ccsid 37 ), 3 )
from t1
group by num;