mssqlはmysql groupに似ています.concatの関数
428 ワード
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