sqlserver将分组后的结果连接起来
Create table B([id] int,[name] nvarchar(1))
Insert B
select 1,N'a' union all
select 1,N'b' union all
select 2,N'c' union all
select 2,N'd' union all
select 2,N'e'
select * from b
Select ID,STUFF((SELECT ','+Name FROM B WHERE ID=a.ID FOR XML PATH('')) ,1,1,'') AS Name
from B AS a
GROUP BY ID