SQL Server multiple rows of data into a row

selecttype,user_name= (stuff((select ',' + name from tableName where  type= a.type for xml path('')),1,1,''))

from tableName a group by type

 

Similar as Alias ​​--user_name

--name need to integrate database information into a field

--tableName table name

--type group field

Reproduced in: https: //www.cnblogs.com/xy0710/p/11053288.html

Guess you like

Origin blog.csdn.net/weixin_33871366/article/details/92849829