新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
在SQLite中統(tǒng)計本周本月數(shù)據(jù)的代碼實例
假設SQLite數(shù)據(jù)庫中有個表UserConsume,其中有一列rowTime,該列類型是datetime,怎么統(tǒng)計該表本月和本周的數(shù)據(jù)?接下來我們給出了統(tǒng)計的代碼。

成都創(chuàng)新互聯(lián)專注于成都網(wǎng)站制作、成都做網(wǎng)站、網(wǎng)頁設計、網(wǎng)站制作、網(wǎng)站開發(fā)。公司秉持“客戶至上,用心服務”的宗旨,從客戶的利益和觀點出發(fā),讓客戶在網(wǎng)絡營銷中找到自己的駐足之地。尊重和關懷每一位客戶,用嚴謹?shù)膽B(tài)度對待客戶,用專業(yè)的服務創(chuàng)造價值,成為客戶值得信賴的朋友,為客戶解除后顧之憂。
--統(tǒng)計本月數(shù)據(jù)的代碼 如下:
- select *
- from UserConsume
- where rowTime between datetime('now','start of month','+1 second') and
- datetime('now','start of month','+1 month','-1 second')
--統(tǒng)計本周數(shù)據(jù)的代碼如下:
- 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')
關于SQLite數(shù)據(jù)庫統(tǒng)計數(shù)據(jù)就介紹到這里了,如果您想了解更多數(shù)據(jù)庫的知識,也可以去看看這里的文章:http://database./,您的收獲是我***的快樂!
【編輯推薦】
- SQLite FAQ常見問題解答
- SQLite 基本控制臺命令簡介
- SQLite數(shù)據(jù)庫簡介之對表的操作
- MSSQL數(shù)據(jù)庫跨表和跨數(shù)據(jù)庫查詢方法簡介
- NetApp Filers提高數(shù)據(jù)庫的可用性和可靠性
當前標題:在SQLite中統(tǒng)計本周本月數(shù)據(jù)的代碼實例
瀏覽地址:http://m.fisionsoft.com.cn/article/codeccj.html


咨詢
建站咨詢
