SQLServer分组后按字段拼接
SELECT 字段1, [随便来个名字就行] = stuff(( SELECT ',' + [字段2] FROM aa t WHERE t.字段1 = aa.字段1 FOR xml path('')) , 1 , 1 , '') FROM aa GROUP BY 字段1
SELECT 字段1, [随便来个名字就行] = stuff(( SELECT ',' + [字段2] FROM aa t WHERE t.字段1 = aa.字段1 FOR xml path('')) , 1 , 1 , '') FROM aa GROUP BY 字段1