我有一个像三个列像图像(源)的表,并希望编写一个像图像一样的表(结果)
解决方法
SELECT DISTINCT customer,stuff(( SELECT ',' + cast(policy as varchar(10)) FROM table1 b WHERE a.customerid = b.customerid FOR XML path('') ),1,'') [policies] FROM table1 a
SELECT DISTINCT customer,stuff(( SELECT ',' + cast(policy as varchar(10)) FROM table1 b WHERE a.customerid = b.customerid FOR XML path('') ),1,'') [policies] FROM table1 a