本文介绍了我想转移SQL服务器的数据(即列为行和行为列)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的数据如下
CompanyName年销售额TradedSales TotalSales Taxes NetSales RowMaterial
TCS 2017 201 1245 65650 23 3232 323
TCS 2018 122 121 2121 121 21231 2121
Tata Moters 2015 14 54 54 545 456 4548
Tata Moters 2017 2121 12 21 156 565 5656
Tata Moters 2018 7512 5454 545 5454 787 78
SMERA 2017 5544 2121 545 9522 878 121
SMERA 2017 784 787 998 854 545 545
我想要输出为
CompanyName TCS TCS [Tata Moters] [Tata Moters] [Tata Moters] SMERA SMERA
2017年2018 2015 2017 2018 2017 2017
销售额201 122 14 2121 7512 5544 784
TradedSales 1245 121 5 4 12 5454 2121 784
TotalSales 65650 21 21 54 21 545 998
税23 21 545 156 5454 9522 854
NetSales 3232 21231 456 565 787 878 121
RowMaterial 323 2121 4548 5656 78 121 545
多年来还有许多公司数据因此想要解决方案动态
我尝试过:
我没有关于Pivot的想法,所以请提前解决问题
的解决方案
解决方案
I have Data as follows
CompanyName Year Sales TradedSales TotalSales Taxes NetSales RowMaterial TCS 2017 201 1245 65650 23 3232 323 TCS 2018 122 121 2121 121 21231 2121 Tata Moters 2015 14 54 54 545 456 4548 Tata Moters 2017 2121 12 21 156 565 5656 Tata Moters 2018 7512 5454 545 5454 787 78 SMERA 2017 5544 2121 545 9522 878 121 SMERA 2017 784 787 998 854 545 545 I want Output as CompanyName TCS TCS [Tata Moters] [Tata Moters] [Tata Moters] SMERA SMERA Year 2017 2018 2015 2017 2018 2017 2017 Sales 201 122 14 2121 7512 5544 784 TradedSales 1245 121 54 12 5454 2121 784 TotalSales 65650 21 21 54 21 545 998 Taxes 23 21 545 156 5454 9522 854 NetSales 3232 21231 456 565 787 878 121 RowMaterial 323 2121 4548 5656 78 121 545 also there are many companies data for many years so Want solution dynamic What I have tried: I dont have Idea About Pivot so Please provide solution for problem thanks in advance
解决方案
这篇关于我想转移SQL服务器的数据(即列为行和行为列)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!