nikhila reddy
nikhila reddy

Reputation: 63

concatenating the two column values of different rows into one in teradata

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

Answers (1)

dnoeth
dnoeth

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

Related Questions