MySQL get average values per hour from the last 24 hours
mysql, sql
Solution
You have to mention the last 24 hours data:
SELECT id, serverID, AVG(performance) as performance, AVG(online) as online,
HOUR(timestamp) FROM stats_server
WHERE serverID= :serverID AND DATE_SUB(`timestamp`,INTERVAL 1 HOUR) And
timestamp > DATE_SUB(NOW(), INTERVAL 1 DAY)
GROUP BY HOUR(timestamp)
ORDER BY id ASC
Problem
I use the following query to get the average values per hour for one day, but I don't get it to result the latest data instead of the oldest: ``` SELECT id, serverID, AVG(performance) as performance, AVG(online) as online, HOUR(timestamp) FROM stats_server WHERE serverID= :serverID AND DATE_SUB(`timestamp`,INTERVAL 1 HOUR) GROUP BY HOUR(timestamp) ORDER BY id ASC ```