【问题标题】:How to sort by month name in access pivot column?如何在访问数据透视列中按月份名称排序?
【发布时间】:2018-02-10 11:42:45
【问题描述】:

我有以下枢轴查询:

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]));

效果很好,但月份名称(列)按字母顺序排序,而不是按月份编号。

上面的查询按以下顺序给我列:April, August, December, February ...

我想要几个月的正常顺序:1 月、2 月、3 月 ...

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

【问题讨论】:

    标签: ms-access


    【解决方案1】:

    你这样做:

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

    【讨论】:

      猜你喜欢
      • 2018-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-03
      • 2017-04-23
      • 1970-01-01
      • 2018-06-11
      相关资源
      最近更新 更多