title: SQLite query Join
body: <p>I have a query I need to perform in SQLite that is probably fairly simple but I cannot seem to figure out a solution.</p>
  
  <p>I have two tables formed as such:</p>
  
  <pre><code>  table_1
  value | timestamp
  x1    | 0
  x2    | 1
  x3    | 2
  x4    | 3
  x5    | 4
  
    table_2
  start | end
  0     |  1
  2     |  4
  </code></pre>
  
  <p>I want to return a result that looks like:</p>
  
  <pre><code> start  |   end   |       computed_value
   0      |    1    |    avg(x1,x2) * (1 - 0)
   2      |    4    |    avg(x3,x4,x5) * (4 - 2)
  </code></pre>
  
  <p>Where avg(x1,x2) is the actual average values of x1 and x2.  How can I complete this task?</p>