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"; 

    2 answers 2

    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 :-)

    • @ Чад Either I did not understand, or you. Just in case, I will clarify. It is necessary to get all 100,500 records for the entire period with a difference of one hour. group by hour (data) Will give 24 records (one for each hour) - zenith
    • one
      Maybe then group by date (data), hour (data) - alexlz
    • @zenith, Well, once you understand the idea, what's the problem? :-) - Chad
     GROUP BY DATE_FORMAT(data, "%Y-%m-%d %H")