Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
taniarto
Starting Member
27 Posts |
Posted - 2013-06-29 : 02:29:42
|
Dear All,I Have data for example :ID qtyA001 100A001 100B001 200B001 100C001 500I want to make view like :ID A001 B001 C001A001 200 0 0B001 0 300 0C001 0 0 500is it possible ?thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-29 : 14:58:12
|
[code]SELECT ID,[A001],[B001],[C001]FROM (SELECT ID,ID AS PivotID,SUM(qty) AS qty FROM Table GROUP BY ID)tPIVOT(SUM(qty) FOR PivotID IN ([A001],[B001],[C001]))p[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|