sql server - T-SQL Concatenate & group multiple rows into a single row -
this question has answer here:
- concatenate many rows single text string? 38 answers
i'm looking way group whilst concatenating rows comma separated string. example:
name place steve jones new york steve jones washington albert smith miami albert smith denver to ...
steve jones new york, washington albert smith miami, denver greatly appreciated
you can use string_agg if using 2017, sql azure else can query below:
select [name], places = stuff((select ', '+place yourtable [name] = t.[name] xml path('')),1,2,'') yourtable group [name]
Comments
Post a Comment