之前我们解释了SQL Server 2008 PIVOT 数据透视表
UNPIVOT 表与 PIVOT 表相反。
Unpivot表示例
SELECT CustomerName, ProductName, QuantityNeeded FROM ( SELECT ProductName,John,Mike FROM ( SELECT CustomerName, ProductName, QuantityNeeded FROM ProductSales) up PIVOT (SUM(QuantityNeeded) FOR CustomerName IN (John,Mike)) AS [pivot]) p UNPIVOT (QuantityNeeded FOR CustomerName IN (John,Mike) ) AS [unpivot] GO
日期:2020-06-02 22:18:09 来源:oir作者:oir