如何按访问数据透视表列中的月份名称排序?

时间:2017-09-01 11:52:26

标签: ms-access

我有以下数据透视查询:

TRANSFORM Sum(Forecast.Openquantity) AS OpenQty
SELECT Forecast.Material, Forecast.Description, Forecast.Unrestricted
FROM Forecast
GROUP BY Forecast.Material, Forecast.Description, Forecast.Unrestricted
ORDER BY Forecast.Material, Forecast.Description, MonthName(Month([Forecast].[LoadingDate]))
PIVOT MonthName(Month([Forecast].[LoadingDate]));

工作正常,但月份名称(列行)按字母顺序排序,而不是按月份编号。

上面的查询按顺序给我列:4月,8月,12月,2月......

我想要几个月的正常订单:1月,2月,3月......

如何更改此查询以便对月份名称列进行正确排序?

1 个答案:

答案 0 :(得分:2)

你这样做:

PIVOT MonthName(Month([Forecast].[LoadingDate])) IN ("January","February", ... ,"December");