Concatenate strings from multiple records in Teradata SQL -
i have list of merchants business in different states.
merch state nc fl b ca b va
instead of returning 4 records want group merch concatenate strings of states output looks like
merch states nc,fl b ca,va
i'm having lot of trouble translating response in answer issue optimal way concatenate/aggregate strings
i cannot string_agg work, i'm not sure works in teradata. https://docs.microsoft.com/en-us/sql/t-sql/functions/string-agg-transact-sql
you can use xml_agg()
built in function in teradata. doesn't translate sql server why having issues 2 links.
select merch, trim(trailing ',' (xmlagg(states || ',' order states) (varchar(500)))) yourtable group 1;
Comments
Post a Comment