在sqlite中怎么统计本周本月数据,sqlite统计本周本月
sqlite中有个表UserConsume,其中有一列rowTime,该列类型是datetime,怎么统计该表本月和本周的数据?sql如下:
--本月
select *
from UserConsume
where rowTime between datetime('now','start of month','+1 second') and
datetime('now','start of month','+1 month','-1 second')
--本周
select *
from UserConsume
where rowTime between datetime(date(datetime('now',strftime('-%w day','now'))),'+1 second')
and datetime(date(datetime('now',(6 - strftime('%w day','now'))||' day','1 day')),'-1 second') 主要用的函数有datetime和strftime,具体用法,请参阅官网:http://www.sqlite.org/lang_datefunc.html
sql,请参阅:http://sqlite.org/lang.html
数据类型,请参阅:http://sqlite.org/datatype3.html
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。