sql server - T-SQL Concatenate & group multiple rows into a single row -


this question has answer here:

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

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -