-1

Let's say my select statement in t-sql returns

John Smith | Chicago | a  
John Smith | Chicago | f  
John Smith | Chicago | j  
Josh Dude  | Houston | p  
Josh Dude  | Houston | s  

And I want it to return

John Smith | Chicago | a, f, j  
Josh Dude  | Houston | p, s

How would I do that?

S3S
  • 24,809
  • 5
  • 26
  • 45
  • 3
    Possible duplicate of [Sql PIVOT and string concatenation aggregate](http://stackoverflow.com/questions/14783680/sql-pivot-and-string-concatenation-aggregate) – S3S Aug 03 '16 at 18:12
  • Did you try anything to solve your issue? – dfundako Aug 03 '16 at 18:33

1 Answers1

0

The first half of the article T-SQL: Normalized data to a single comma delineated string and back is a code and image-heavy tutorial on how you can use STUFF and a FOR XML PATH statement take a normalized set and turn one column into a single comma separated value.

Good luck.

Jim Horn
  • 879
  • 6
  • 14