一.定义表变量 DECLARE @T1 table ( UserID int , UserName ), CityName ) ); ,'a','上海') ,'b','北京') ,'c','上海') ,'d','北京') ,'e','上海') select * from @T1 -----最优的方式 , , '') AS A FROM @T1 A GROUP BY CityName ----第二种方式 ) FROM ( SELECT CityName,(SELECT UserName+',' F…