select ID, Name = ( stuff ( ( select ',' + Name from Table_1 where ID = a.ID for xml path('') ),1,1,'' ) ) from Table_1 a group by ID
原始数据:
ID Name A S A M A L B S B M B L
结果数据:
ID NameA S,M,LB S,M,L