首页 > 代码库 > 多列转一行

多列转一行

select [Document No_],STUFF ((select ‘ ,‘+[Item No_]+‘: ‘+Convert(varchar(20),Convert(int,[Qty_ Per Pallet]))+

‘ ‘+[Packing Unit of Measure]+‘ * ‘+Convert(varchar(20),Convert(int,[Packing Qty_ per]))+‘ ‘+[Unit of Measure Code]
from [Line] as tb01
where tb01.[Document No_]=tb02.[Document No_] for xml path(‘‘)),1,2,‘‘) as speclist
from [Line] as tb02
where tb02.[Document No_] in (‘A1‘,‘A2‘,‘A3‘)
group by [Document No_]

多列转一行