报表数据汇总,年份在左边一列,月份在顶部一行
SELECT Privotorders.*
FROM (SELECT YEAR(OrderDate) AS OrderYear, FORMAT(OrderDate,'MMMM','en-US') AS OrderMonth,ExtendedAmount FROM FactInternetSales) AS Privotorders
PIVOT (SUM(ExtendedAmount) FOR OrderMonth IN ([January],[February],[March],[April],[May],[June],[July],[August],[September],[October],[November],[December])) Privotorders
学习笔记;