mysql如何取得規(guī)定時(shí)間段內(nèi)的統(tǒng)計(jì)數(shù)據(jù)的代碼詳細(xì)說(shuō)明
發(fā)表時(shí)間:2023-09-06 來(lái)源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]這篇文章主要介紹了mysql 獲取規(guī)定時(shí)間段內(nèi)的統(tǒng)計(jì)數(shù)據(jù)的相關(guān)資料,需要的朋友可以參考下mysql 獲取規(guī)定時(shí)間段內(nèi)的統(tǒng)計(jì)數(shù)據(jù)按年統(tǒng)計(jì)SELECT count(*), DATE_FORMAT(order_info.create_time, %Y-%m-%d) AS count_by_date FR...
這篇文章主要介紹了
mysql 獲取規(guī)定時(shí)間段內(nèi)的統(tǒng)計(jì)數(shù)據(jù)的相關(guān)資料,需要的朋友可以參考下
mysql 獲取規(guī)定時(shí)間段內(nèi)的統(tǒng)計(jì)數(shù)據(jù)
按年統(tǒng)計(jì)
SELECT
count(*),
DATE_FORMAT(order_info.create_time, '%Y-%m-%d') AS count_by_date
FROM
order_info
WHERE
DATE_FORMAT(order_info.create_time, '%Y') = '2017'
GROUP BY
count_by_date
ORDER BY NULL
按月統(tǒng)計(jì)
SELECT
count(*),
DATE_FORMAT(order_info.create_time, '%Y-%m-%d') AS count_by_date
FROM
order_info
WHERE
DATE_FORMAT(order_info.create_time, '%Y-%m') = '2017-04'
GROUP BY
count_by_date
ORDER BY NULL
具體變換可以自己根據(jù)需求變更
以上就是mysql如何獲取規(guī)定時(shí)間段內(nèi)的統(tǒng)計(jì)數(shù)據(jù)的代碼詳解的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注php中文網(wǎng)其它相關(guān)文章!
學(xué)習(xí)教程快速掌握從入門(mén)到精通的SQL知識(shí)。