表是 GroupID CountryName
1 中国
1 美国
1 德国
现在要的结果是 GroupID,CountryName
1 中国、美国、德国
求好方法。。
------解决方案--------------------
select a.GroupID,
stuff((select '、'+b.CountryName
from [表名] b
where b.GroupID=a.GroupID
for xml path('')),1,1,'') 'CountryName'
from [表名] a
group by a.GroupID