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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -