title: MySQL get average values per hour from the last 24 hours
body: <p>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:</p>
  
  <pre><code>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
  </code></pre>