Reputation: 63
I have table with the below data in teradata database
cstmr_id | name 1 | aaaaaa 1 | bbbbbb 2 | cccccc 2 | dddddd
I want the output to be like 1 | aaaaaa,bbbbbb 2 | cccccc,dddddd
The output should be written to another table. All this needs to be done in teradata.
Thanks in Advance, Nikhila
Upvotes: 0
Views: 3143
Reputation: 60462
What's your Teradata release? Are XML services installed?
SELECT cstmr_id,
RTRIM(XMLAGG(name || ','
ORDER BY name
) (VARCHAR(1000)),',')
FROM tab
GROUP BY 1
Upvotes: 1