本文介绍了sqlserver:将行转换为动态列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我使用sqlserver 2012 Express 我有这个选择 选择C.COMPUTER_NAME,A .PART_NAME 来自Projects.PARTS_ON_COMPUTERS P 左加入Projects.COMPUTERS C ON C.Id = P.COMPUTER LEFT JOIN Projects.COMPUTER_PARTS A ON A.Id = P.PART 给出mes结果 computer_Name part_name -------------------------------------------- pc1硬200g pc1显卡 pc1网卡 pc2硬500g pc2显卡 但是我需要的结果是 pc1硬200g显示卡网卡 b $ b pc2硬500g显示卡 请帮忙I use sqlserver 2012 ExpressI have this selectselect C.COMPUTER_NAME, A.PART_NAMEfrom Projects.PARTS_ON_COMPUTERS Pleft join Projects.COMPUTERS C ON C.Id= P.COMPUTERLEFT JOIN Projects.COMPUTER_PARTS A ON A.Id= P.PARTgives mes resultscomputer_Name part_name--------------------------------------------pc1 hard 200gpc1 display cardpc1 network cardpc2 hard 500gpc2 display cardbut I need the results to bepc1 hard 200g display card network cardpc2 hard 500g display cardplease help推荐答案我怀疑你真的不需要这个,并且转换会更好地完成。代码。 但如果你*真的*需要在SQL,看看PIVOT和UNPIVOT。 哦,看看页面右边的'相关问题'......I suspect you don't really need to this, and the transformation would be better done in .the code.But if you *really* need to do it in SQL, look at PIVOT and UNPIVOT.Oh, and take a look over on the right of the page at 'Related Questions'... 这篇关于sqlserver:将行转换为动态列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-11 15:26