【问题标题】:Access Group By Month Names Using Format Function使用格式函数按月份名称访问组
【发布时间】:2015-01-29 19:06:40
【问题描述】:

我无法在 MS Access 数据库中按月份名称排序顺序

我正在使用格式函数来检索月份名称(如果我使用 MonthName(Month(date)) 函数查询正在 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 

【问题讨论】:

    标签: ms-access ms-access-2007


    【解决方案1】:

    添加月份(数字)列但不显示如何?

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

    请注意,我在 [] 中包含了日期,这是因为日期是保留字,不应用作列/字段名称。

    【讨论】:

    • 你太棒了,谢谢它对我有很大帮助
    • 不客气。请单击“绿色勾号”将其标记为答案,以便其他人受益。
    • 完成!现在你的帮助对我来说是无数的代价!
    • 很高兴能帮上忙! :) 祝你好运
    猜你喜欢
    • 2018-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-30
    • 2018-02-10
    • 2010-09-16
    • 1970-01-01
    相关资源
    最近更新 更多