PCB SQL MS 将多行有序数据转为一行数据(一列转一行)

 

一.原数据:多行有序

SELECT CC.techname
FROM PPEflow BB LEFT JOIN pubgyxxb CC  ON BB.techno = CC.techno 
WHERE  BB.Pdctno =  'AT00101CA0' AND bb.flowLevel = 2 
ORDER BY  BB.globalOrder 

 

二.转换后数据:

SELECT  '' + CC.techname  + '】-→' + '' 
FROM PPEflow BB LEFT JOIN pubgyxxb CC  ON BB.techno = CC.techno 
WHERE  BB.Pdctno =  'AT00101CA0' AND bb.flowLevel = 2 
ORDER BY  BB.globalOrder 
FOR XML PATH('')

 

posted @ 2018-06-30 18:49  pcbren  阅读(177)  评论(0编辑  收藏  举报