Hi, How to calculate column totals using PIVOT in SQL Server 2008 R2. I would like to get column totals for each employee. Can this be done in T-SQL?
USE AdventureWorks2008R2 GO SELECT VendorID, [250] AS Emp1, [251] AS Emp2, [256] AS Emp3, [257] AS Emp4, [260] AS Emp5 FROM (SELECT PurchaseOrderID, EmployeeID, VendorID FROM Purchasing.PurchaseOrderHeader) p PIVOT ( COUNT (PurchaseOrderID) FOR EmployeeID IN ( [250], [251], [256], [257], [260] ) ) AS pvt ORDER BY pvt.VendorID GOThanks in advance..............