SQL Server 多行数据转换成一行

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

猜你喜欢

转载自blog.csdn.net/weixin_33871366/article/details/92849829