分组查询连接字段
select [分组字段],stuff((select ',' + [连接字段] from [表] where [分组字段]=a.[分组字段] for xml path('')),1,1,'') as name
from [表] a group by [分组字段]
select [分组字段],stuff((select ',' + [连接字段] from [表] where [分组字段]=a.[分组字段] for xml path('')),1,1,'') as name
from [表] a group by [分组字段]
作者:SunSpring
出处:https://www.cnblogs.com/SunSpring/p/15166988.html
本文版权归作者所有,欢迎转载,但未经作者同意需在文章页面明显位置给出原文链接。