title: Mysql query to get trend of temperature
body: <p>I have a very large table where I have temperatures getting logged every 1 mins, what I would like to query is a trend; something like a percentage increase or percentage decrease per selected period ( hour or 15mins; depending on the query) </p>
  
  <p>my table looks (example)  like the following</p>
  
  <pre><code>ID      time                temp
  119950  2013-03-27 07:56:05 27.25
  119951  2013-03-27 07:57:05 27.50
  119952  2013-03-27 07:58:05 27.60
  119953  2013-03-27 07:59:05 27.80
  119954  2013-03-27 08:00:05 27.70
  119955  2013-03-27 08:01:05 27.50
  119956  2013-03-27 08:02:05 27.25
  119957  2013-03-27 08:03:05 27.10
  119958  2013-03-27 08:04:05 26.9
  119959  2013-03-27 08:05:05 27.1
  119960  2013-03-27 08:06:05 27.25
  119961  2013-03-27 08:07:05 27.6
  </code></pre>
  
  <p>I believe a trend can be calculated as follow (as per <a href="http://www.wikihow.com/Calculate-the-Rate-of-Temperature-Increase" rel="nofollow">link</a>), but correct me if you have a better way;
  take the difference between each row then add then up and divide by count. so for the table above we get</p>
  
  <pre><code>Diff
  +0.25
  +0.10
  +0.20
  -0.10
  -0.20
  -0.25
  -0.15
  -0.20
  +0.20
  +0.15
  +0.35
  </code></pre>
  
  <p>The trend per minute for last 11 minutes is sum of diff/11. which gives 0.063C per minute for last 11minutes.</p>
  
  <p>Can someone please help me get percentage trend per hour for last 3 hours. and trend per minute for 1 hour? </p>