Answer the question
In order to leave comments, you need to log in
How to sample data for the last 24 hours in hourly mode?
For example, you need to display all the data for the last day but ... from 00 to 6 hours, from 6 to 12 hours, from 12 to 18, from 10 to 24. How to build such a query? Or one request and then how to process it in php? (again - how to do it?)
Answer the question
In order to leave comments, you need to log in
SELECT
FLOOR(HOUR(date_time) / 6) AS period,
AVG(temperature) AS avg_temperature
FROM table_name
WHERE date_time > DATE_SUB(NOW(), INTERVAL 1 DAY)
GROUP BY FLOOR(HOUR(date_time) / 6)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question