sql多行合并一列
with a as( select * from( select 1 userId , '天津' province union select 1 userId , '北京' union select 1 userId , '上海' union select 2 userId , '北京' union select 2 userId , '上海' ) model ) select distinct userId, stuff( (select ','+province from a where userId=a2.userId for xml path('') ),1,1,'') 合并 from a as a2