我无法按MS Access数据库中的月份名称排序订单
我正在使用格式函数来检索月份名称(如果我使用MonthName(月(日期))功能查询正在Access DB上执行(但是当我尝试从我的应用程序使用相同的查询时,我得到错误
My Query is
这是我的查询(代码)Used all the Functions of Format But I am Unable to Order By MonthNames
SELECT Format(date ,"mmmm") as MonthName,
Sum(Rojnamchatable.asal1) AS SumOfasal1,
Sum(Rojnamchatable.chaat1) AS SumOfchaat1,
SumOfasal1+SumOfchaat1 AS TotalBiri1,
Sum(Rojnamchatable.asal2) AS SumOfasal2,
Sum(Rojnamchatable.chaat2) AS SumOfchaat2,
SumOfasal2+SumOfchaat2 AS TotalBiri2,
GROUP BY Format(date ,"mmmm")
ORDER BY Format(date ,"mmmm")
I am Getting Data Perfectly But I am unable to get Order By Month Name
(i.e Jan ,Feb ,March)
I Even Used Format(date,"mm") Function If I Use that I am getting Erors
So Please try to Solve My Issue
I Spent 2 days for this
答案 0 :(得分:2)
如何添加月份(数字)列但不显示它?
SELECT
Format([date] ,"mmmm") as MonthName,
Sum(Rojnamchatable.asal1) AS SumOfasal1,
Sum(Rojnamchatable.chaat1) AS SumOfchaat1,
SumOfasal1+SumOfchaat1 AS TotalBiri1,
Sum(Rojnamchatable.asal2) AS SumOfasal2,
Sum(Rojnamchatable.chaat2) AS SumOfchaat2,
SumOfasal2 + SumOfchaat2 AS TotalBiri2,
FROM
yourTableName
GROUP BY
Format([date] ,"mmmm"), Month(date)
ORDER BY
Month([date])
请注意我在[]中附上日期,这是因为Date是保留字,不应该用作列/字段名称。