例:id name 1 A 1 B 1 C 2 a 2 b结果:id 别名1 A,B,C2 a,b 方法:sql2005+的实现。SELECT id,STUFF((SELECT ','+name FROM Test WHERE id=T.id FOR XML PATH('')),1,1,'') AS 别名 FROM Test T GROUP BY T.id