I'm using SQL Server and TSQL:
What I would like to do is comma separate values on one column when using a group by on another column. See data example below.
col1 --- col2 1121 abc 1123 aee 1335 afg 1121 def 1121 abc
I would like to Group By on "col1" and count the number of records, but I would also like to concatenate on col2 if the data is different. For instance, using value "1121" as a reference, see the data output below.
qty --- col1 --- col2 3 1121 abc, def 1 1123 aee 1 1335 afg
I thought of maybe using COALESCE, but I'm not sure how to implement it when using group by on another column.
Any help would be greatly appreciated.