发布网友 发布时间:2022-04-10 10:33
共2个回答
热心网友 时间:2022-04-10 12:02
简单啊,先用row_number 获取 No顺序,然后通过 STUFF FOR XML PATH 获取顺序号转成字段
通过动态SQL利用PIVOT行列
热心网友 时间:2022-04-10 13:20
Select fgroup,max(case when nid=1 then fnum else null end) as fnum1,max(case when nid=2 then fnum else null end) as fnum2,max(case when nid=3 then fnum else null end) as fnum3,max(case when nid=4 then fnum else null end) as fnum4,max(case when nid=5 then fnum else null end) as fnum5from table group by fgroup