I am trying to concatenate demographic data. Customers are allowed to enter multiple responses (up to five) for their race/ethnicity. The data is stored in its own table listing the results by line number. I would like to concatenate the responses so the data is displayed in one field (rather than multiple rows) and so each customer only has one race/ethnicity. Any suggestions?
I find it easiest to perform the text aggregation in the data provider (command object). You will have to write the SQL to do it. This is one method using Oracle:
Select Customer_ID,
Replace(SubStr(Max(Sys_Connect_By_Path(DemoData, ‘|#$’)), 4, 4000), ‘|#$’, Chr(10)) DemoData
From (Select NPMT.Customer_ID,
Replace(Replace(Trim(DemoData.DemoData), Chr(13), Chr(10)), Chr(10) || Chr(10), Chr(10)) DemoData,
Row_Number() over (PARTITION BY DemoData.Customer_ID Order By DemoData.RowID) RowNumber
From DemoData
Order by DemoData.Customer_ID)
Where Level = RowNumber
Connect by Prior RowNumber = RowNumber - 1 and
Prior Customer_ID = Customer_ID
Group by Customer_ID
Without knowing your data structure this is just a guess.