答案 0 :(得分:1)
select distinct t.[name],
STUFF((SELECT distinct ', ' + t1.notification
from yourtable t1
where t.[id] = t1.[id]
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)')
,1,2,'') notification
from yourtable t;
答案 1 :(得分:1)
SELECT id , Name ,
STUFF ( ( SELECT ',' + Noti FROM Your_table T1 WHERE T1.Id = T2.Id FOR XML PATH('') ) ,1,1,'')
FROM Your_table T2 GROUP BY id ,Name