SELECT DISTINCT [列名]
,STUFF(
(
SELECT ','+[列名]
FROM [表名]
WHERE [根据哪一列合并的列名]= A.列名
FOR XML PATH('')
)
,1,1,''
)AS 合并的别名
FROM [表名] AS 表的别名(A)
SELECT DISTINCT [列名]
,STUFF(
(
SELECT ','+[列名]
FROM [表名]
WHERE [根据哪一列合并的列名]= A.列名
FOR XML PATH('')
)
,1,1,''
)AS 合并的别名
FROM [表名] AS 表的别名(A)