title: Get average day or week values
body: <p>I have statistical data like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>time        val1
  1424166578  51
  1424166877  55
  1424167178  57
  1424167477  57  
  </code></pre>
  
  <p><code>time</code> is a unix timestamp. There is one record every 5 minutes excluding nights and sundays. This continues over several weeks.</p>
  
  <p>Now I want to get these values for an average day and an average week. The result should include values for every 5 minutes like normal but for average past days or weeks.</p>
  
  <p>The result should look like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>time    val1
  0       43.423
  300     46.635
  600     51.887
  ...
  </code></pre>
  
  <p>So time could be a timestamp with relative time since day or week start. Perhaps it is better to use <code>DATETIME</code>... not sure.</p>
  
  <p>If I use <code>GROUP BY FROM_UNIXTIME(time, '%Y%m%d')</code> for example I get one value for the whole day. But I want all average values for all days.</p>