title: SQL query on a time series to calculate the average
body: <p>I have two tables:</p>
  
  <p>temperature table which contains a time series of temperature taken every 15 minutes
  <img src="https://i.stack.imgur.com/tha9q.png" alt="enter image description here"></p>
  
  <p>time table</p>
  
  <p><img src="https://i.stack.imgur.com/33FrV.png" alt="enter image description here"></p>
  
  <p>I need a SQL query, which will allow for an average group by 15 minutes avry values taken for several days</p>
  
  <p>can anyone help me please?</p>
  
  <p>example: for 3 days</p>
  
  <pre><code>day1:00:00-&gt;10 ; 00:15-&gt;11 ;00:30-&gt;9......;23:45-&gt;12
  day2:00:00-&gt;9 ; 00:15-&gt;2 ;00:30-&gt;5......;23:45-&gt;4
  day3:00:00-&gt;8 ; 00:15-&gt;10 ;00:30-&gt;8......;23:45-&gt;5
  </code></pre>
  
  <p>how calculate:</p>
  
  <pre><code>avarage1 =10+9+8/3
  avarage2 =11+2+10/3
  avarage3=9+5+8/3
  ...
  avarage96=12+4+5/3
  </code></pre>
  
  <p>help me please</p>