Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Selecione dados entre 2 datas e saída média por hora


Tente esta consulta
SELECT
   AVG(Temp) AS Temp,
   DATE_FORMAT(Timestamp, '%Y-%m-%d %H:00:00') AS Time
FROM Table
WHERE DATE_FORMAT(Timestamp, '%Y-%m-%d %H:00:00') >= DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -1 DAY), '%Y-%m-%d %H:00:00')
GROUP BY DATE_FORMAT(Timestamp, '%Y-%m-%d %H:00:00')