Jika Anda ingin menggabungkan nilai di seluruh baris, gunakan trik FOR XML, mis.:
SELECT Name + ','
FROM Project
FOR XML PATH('')
Berikut adalah contoh yang lebih lengkap:
select LineItemID, (
Select m.Material + ','
From test.Materials m
inner join test.LineItems_Materials lm1 on m.MaterialID = lm1.MaterialID
Where m.MaterialID in (select MaterialID from test.LineItems_Materials where LineItemID = lm2.LineItemID)
FOR XML PATH('')
) as Materials
from test.LineItems_Materials lm2
group by LineItemID