Aggregate SQL query grouping by month

前端 未结 5 1733
忘掉有多难
忘掉有多难 2021-01-20 06:52

I have a database of Transactions (Access 2007) that are recorded in hourly, daily and monthly intervals. I would like to view them in a meaningful way (instead of hour-by-

5条回答
  •  南方客
    南方客 (楼主)
    2021-01-20 07:36

    something like...

    SELECT Month(UsageTable.TransactionDate) & '/' & Year(UsageTable.TransactionDate) AS BillingPeriod, Sum(UsageTable.Usage) AS Usage
    FROM UsageTable
    WHERE (((UsageTable.TransactionDate) Between [Some Start Date] And [Some End Date]))
    GROUP BY Month(UsageTable.TransactionDate) & '/' & Year(UsageTable.TransactionDate);
    

提交回复
热议问题