Such a request will return all records for the period, but you need to receive one for each hour.
select * from test where obj_id = 297 AND data between "2006-06-01 00:00:00" AND "2013-08-06 23:00:00"; UPD
group by year(data), month(data), day(data), hour(data) And for what fields and how to aggregate multiple records in one hour, I think decide :-)
GROUP BY DATE_FORMAT(data, "%Y-%m-%d %H") Source: https://ru.stackoverflow.com/questions/242137/
All Articles