列转行?

select top 10 orderid,
stuff((select ','+product_no from orderdetail where o.orderid=orderid
group by orderid,product_no for xml path('')),1,1,'')
from orderdetail o group by orderid

原文地址:https://www.cnblogs.com/xiguanjiandan/p/2971113.html