mssql 类似于mysql group_concat 的函数

select top 10 wid, stuff(
	(select ','+convert(varchar(25), rwid) from CombineBuying as t2 where t2.wid = t1.wid FOR XML PATH('')), 1, 1, ''
) as rwids from CombineBuying as t1 where t1.wid = '1003376649'  group by wid

 结果:

wid rwid
1003376649 214474,187698,188549,259662,187701,209419,301721,187678,160848,212992,187248

猜你喜欢

转载自medicine.iteye.com/blog/1767078