回答
基本例子:
USE AdventureWorks2008R2; GO SELECT DaysToManufacture, AVG(StandardCost) AS AverageCost FROM Production.Product GROUP BY DaysToManufacture;
更高級的例子
-- Pivot table with one row and five columns SELECT 'AverageCost' AS Cost_Sorted_By_Production_Days, [0], [1], [2], [3], [4] FROM (SELECT DaysToManufacture, StandardCost FROM Production.Product) AS SourceTable PIVOT ( AVG(StandardCost) FOR DaysToManufacture IN ([0], [1], [2], [3], [4]) ) AS PivotTable;
專家舉例:
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;
希望它可以幫助
- 1. SQL Server 2008 R2 - 樞軸用法?
- 2. SQL 2008 R2中的樞軸
- 3. SQL-Server 2008中的樞軸表
- 4. SQL Server 2008中樞軸和的毗連
- 5. SQL Server:樞軸
- 6. SQL Server 2008中樞軸視圖
- 7. 集團通過在SQL Server樞軸2008
- 8. SQL Server 2008 R2和SQL Server 2008 R2 RTM之間的差異
- 9. SQLDependency SQL Server 2008 R2
- 10. SQL Server 2008 R2 OBJECT_ID
- 11. 從SQL Server 2008 R2 Express升級到SQL Server 2008 R2企業
- 12. SQL - 樞軸/ Unpivot?
- 13. SQL SERVER樞軸溶液
- 14. 在sql server中樞軸
- 15. 總樞軸在SQL Server
- 16. 樞軸查詢 - SQL Server 2005
- 17. SQL Server樞軸問題
- 18. SQL Server:與分組樞軸
- 19. 在SQL Server樞軸列
- 20. SQL Server 2008 R2中的SQL Server Reporting Services
- 21. SQL Server 2008 R2的性能
- 22. 檢測SQL Server 2008 R2的
- 23. 的connectionString爲SQL Server 2008 R2
- 24. SQL Server 2008 R2的MDX GETDATE()
- 25. 動態SQL樞軸由列的SQL Server
- 26. SQL Server 2000到SQL Server 2008 R2遷移
- 27. SQL Server 2008 R2對SQL Server 2012
- 28. 針對樞軸查詢的SQL Server 2008動態標題(每週)
- 29. SQL Server 2008的樞軸不與集合函數
- 30. SQL Server 2008中,樞軸沒有骨料機能的研究