2019-03-28 SQL Server Pivot-LMLPHP

--现在我们是用PIVOT函数将列[WEEK]的行值转换为列,并使用聚合函数Count(TotalPrice)来统计每一个Week列在转换前有多少行数据,语句如下所示
select *
from ShoppingCart as C
PIVOT(count(TotalPrice) FOR [Week] IN([1],[2],[3],[4],[5],[6],[7])) AS T

2019-03-28 SQL Server Pivot-LMLPHP

05-23 18:49