时间:2021-07-01 10:21:17 帮助过:1人阅读
Name Team
------------------------- -------------------------
Jack Team1
Rose Team1
Cindy Team1
Richard Team2
Jenny Team2
SELECT T1.Team, STUFF(( SELECT CONCAT(‘/‘,T2.Name) FROM STUDENT T2 WHERE T2.Team=T1.Team FOR XML PATH(‘‘) ),1,1,‘‘) AS NAMES FROM STUDENT T1 GROUP BY T1.Team
Team NAMES
------------------------- ---------------------------------------------------------
Team1 Jack/Rose/Cindy
Team2 Richard/Jenny
T-SQL 合并多行数据显示到一行
标签: