Skip to content Skip to sidebar Skip to footer

Group By Concat Teradata

I have a problem with a table, I would like to concat a string field using a group by. I have this situation here: USER | TEXT A | 'hello' A | 'by' B | 'hi' B | '9' B

Solution 1:

You can try using xmlagg

SELECT
   User
  ,TRIM(TRAILING ' ' FROM (XMLAGG(TRIM(text)|| ','
                           ORDER BY ColumnPosition) (VARCHAR(1000))))
FROM table
GROUP BY 1

Post a Comment for "Group By Concat Teradata"