sql 中对分组的信息进行聚合。(sql server 2005)

it2026-05-24  16

代码 with  t  as ( select   1  id,  ' Child1 '  child union select   1  id,  ' Child2 ' union select   1  id,  ' Child3 ' union select   2  id,  ' Child1 ' union select   2  id,  ' Child2 ' ) select  id,  stuff (( select   ' , ' + child                  from  t a                  where  b.id  =  a.id                  for  xml path( '' )), 1 , 1 , '' ) children from  t b  group   by  id

转载于:https://www.cnblogs.com/lfzwenzhu/archive/2010/08/20/1804404.html

最新回复(0)