需要查詢的是每個時間點對應表中資料總量,比如2020-01-01 12:00:00時刻表中總資料量為10萬,2020-01-01 14:00:00時刻表中總資料量為15萬
怎么查詢并回傳時間點和對應的總資料量啊?
uj5u.com熱心網友回復:
select date_format(date,'%Y-%m-%d %H') as d, count(*) as cntfrom table
group by d
uj5u.com熱心網友回復:
謝謝您的回復,但是需要查詢表中資料總量,不是每個小時的總量哈
uj5u.com熱心網友回復:
select d, (select count(*) from table where a.d>=date_format(date,'%Y-%m-%d %H')) as cnt from
(select date_format(date,'%Y-%m-%d %H') d
from table group by d) a
uj5u.com熱心網友回復:
感謝您的回答,已經解決了,非常感謝!
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/33230.html
標籤:MySQL
