selecttype,user_name= (stuff((select ‘,‘ + name from tableName where type= a.type for xml path(‘‘)),1,1,‘‘))
from tableName a group by type
--user_name 别名 类似 as
--name 数据库需要整合到一个字段的信息
--tableName 表名称
--type 分组字段
原文:https://www.cnblogs.com/xy0710/p/11053288.html