Aggregate SQL query grouping by month

前端 未结 5 1803
忘掉有多难
忘掉有多难 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:37

    SELECT MONTH(TransactionDate),YEAR(TransactionDate), SUM(Usage) 
    FROM UsageTable 
    Where (TransactionDate Between [Some Start Date] AND[Some End Date]) 
    GROUP BY MONTH(TransactionDate),YEAR(TransactionDate);
    

提交回复
热议问题