sql 同一字段合并

select a.* from (select id,Detail,partId=(select cast(partId as char(36))+',' from (select * from table) as b where b.id=a.id for xml path(''))

,code

from table a

group by id,Detail,code) a

原文地址:https://www.cnblogs.com/chang1/p/6952715.html