Asked: Apr 23 2008 7:39 PM GMT
Asked by: Mgemmill
String Aggregate Function
AS/400,
DB2/400,
SQL,
AS/400 DB2
I need a report that provides an aggregate of a string column - in this case a concatenation of the values in a comma separated string. There is no such DB2 aggregate function that does this. A stored procedure (or possibly a customer aggregate function?) seems the only likely way to accomplish this and my procedure writing skills are rather basic. Essentially, I need to loop through a cursor and concatenate the values and return the data. Given this data:
'abc123', 'one'
'abc123', 'two'
'def456', 'one'
'def456', 'two'
I want to return it as:
'abc123', 'one,two'
'def456', 'one,two'
Any suggestions would be much appreciated. Thanks.