我有桌子
Building Stairs
A Two
B. Three
C. Two
我需要输出
A,C. Two
B. Three
答案 0 :(得分:0)
您可以这样做:
SELECT DISTINCT STUFF(( SELECT ', ' + b.Building
FROM #table b
WHERE b.Stairs = a.Stairs
FOR XML PATH('') ), 1, 1, '' ) AS Building,
Stairs
FROM #table a