access 数据库写按日期查询SQL
生活随笔
收集整理的這篇文章主要介紹了
access 数据库写按日期查询SQL
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
按具體某一年查詢數據
select sum(amount) from 表名 where format(createtime,"yyyy")=2020
按具體某一年某個月查詢
select sum(amount) from 表名 where format(createtime,"yyyymm")=202001
按月統計某一年的數據
select sum(amount) as total,Month(createtime) as month from (select * from t_records where format(createtime,"yyyy")=2020) group by Month(createtime)
同理,按年統計一段時間內的數據
select sum(a.amount) as total,Year(a.createtime) as year from (select * from t_records where createtime between #2019-1-1 00:00:00# and #2020-12-31 23:59:59#) as a group by Year(createtime)
?
使用時遇到的問題
SELECT 子句中包含一個保留字、拼寫錯誤或丟失的參數,或標點符號不正確。
把你任務是關鍵字的字段使用[]括起來,比如:name字段,查詢時寫成[name]即可。
總結
以上是生活随笔為你收集整理的access 数据库写按日期查询SQL的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 阿里云为机器装上ET大脑 用人工智能开启
- 下一篇: 图网络:从数据处理到DGL模型构建(GC