透视使用两列 [英] Pivot using two columns
本文介绍了透视使用两列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个像这样的表
Id Name typeid typename amount totalamount returnamount
1 raja 501 pendrive 100 100 0
1 raja 502 headphone 120 150 30
1 raja 503 ipod 150 200 50
2 ravi 501 pendrive 100 100 0
2 ravi 502 headphone 120 150 30
2 ravi 503 ipod 150 200 50
3 raju 501 pendrive 100 100 0
3 raju 502 headphone 120 150 30
3 raju 503 ipod 150 200 50
我需要获取像
I need to get the data like
id name typeid amount totalamount returnamount
1 raja 501 100 100 0
502 120 150 30
503 150 200 50
2 ravi 501 100 100 0
502 120 150 30
503 150 200 50
3 raju 501 100 100 0
502 120 150 30
503 150 200 50
否则如何使用两列旋转表并得到结果
Otherwise how to pivot the table using two columns and get the result
推荐答案
检查一下
抑制SQL中重复的列值 [ ^ ]
您所要做的就是根据您的事情自定义查询。
Check this one
Suppressing a repeated column value in SQL[^]
All you have to do is customize the query based on your things.
这篇关于透视使用两列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文