I want to concatenate strings from multiple rows. For example, if I have:
ID TEXT
01 Hello
01 hello I have a question
02 Hi!!
02 Thank you
I want to get something like:
ID TEXT
01 Hello; hello I have a question
02 Hi!!; Thank you
I tried the solution provided here, so my query looks like this:
SELECT ID,
TRIM(TRAILING ',' FROM (XMLAGG(TRIM(TEXT)|| ',' ORDER BY TEXT) (VARCHAR(2000)))) as TEXT
FROM my_table
GROUP BY 1;
But now Teradata returns SELECT Failed: The string contains an untranslatable character.
So I tried with the TRANSLATE function:
SELECT ID,
TRIM(TRAILING ',' FROM (XMLAGG(TRIM(
TRANSLATE(OREPLACE(TRANSLATE(TEXT USING LATIN_TO_UNICODE WITH ERROR),'|','') USING UNICODE_TO_LATIN WITH ERROR)
)|| ',' ORDER BY TEXT) (VARCHAR(2000)))) as TEXT
FROM my_table
GROUP BY 1;
But I'm getting the same error.