Mysql
 sql >> Database >  >> RDS >> Mysql

Seleziona i dati tra 2 date e la produzione oraria media

Prova questa query

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