PIVOT in SQL SERVER 2008

CGN007
Posted by CGN007 under Sql Server category on | Points: 40 | Views : 1497
Input Table

VendorID EmployeeName Orders
--------------------------------------
1 Rahul 5
1 Sourav 3
1 Sunil 9
2 Rahul 8
2 Sourav 4
2 Sunil1 6

SELECT VendorID,[Rahul],[Sourav],[Sunil] 
FROM PurchaseOrder
PIVOT
( sum (Orders)FOR EmployeeName IN ([Rahul],[Sourav],[Sunil] )
) AS p

Output


VendorID Rahul Sourav Sunil
-------------------------------------
1 5 3 9
2 8 4 6

Comments or Responses

Login to post response