Group Byの結果を、カンマ区切りで出力させる時に、for xml pathを使用する。
このようなテーブルを作成し、カラムgrでGroup Byし、stの値をカンマ区切りで出力させる。
declare @table table(
id int,
gr nvarchar(10),
st nvarchar(10)
)
insert into @table values (1, 'group 1', '123'),
(2, 'group 1', '234'),
(3, 'group 2', '345'),
(4, 'group 2', '456'),
(5, 'group 2', '456');

for xml path、stuffを使用し、このようなクエリを書くと、stの値がカンマ区切りとなる。
select gr,
stuff((select ', ' + t2.st
from @table t2 where t1.gr = t2.gr
for xml path('')),
1,2,'') [Values]
from @table t1
group by t1.gr

単純にカンマ区切りとなるため、group 2の方は、456が重複する。
重複を取り除くときはdistinctをかませる。
select gr,
stuff((select distinct ', ' + t2.st
from @table t2 where t1.gr = t2.gr
for xml path('')),
1,2,'') [Values]
from @table t1
group by t1.gr
