title: how to integrate electrical currents in sqlite
body: <p>I could solve the following problem in PHP, but I wonder if it could be done in SQLite.</p>
  
  <p>The simplified version looks like this: I have a simple electrical circuit. I can switch on and off a red, a green and a blue light independently. I record the timing in seconds and electrical current in ampere for each light in a table as follows:</p>
  
  <pre><code>| Lamp  | On | Off | Current |
  |-------|----|:---:|--------:|
  | red   | 2  |  14 |       3 |
  | green | 5  |  8  |       8 |
  | blue  | 6  |  10 |       2 |
  </code></pre>
  
  <p>As you can see, they overlap. If I want to integrate the current properly (to calculate the energy consumption), I have to transform this table to a new one, which adds the electrical currents. I get the following table (manually) with adapted timing:</p>
  
  <pre><code>| T1 | T2 | Sum(Current) |     Comment    |
  |:--:|:--:|-------------:|:--------------:|
  |  2 |  5 |            3 |       red      |
  |  5 |  6 |           11 |    red+green   |
  |  6 |  8 |           13 | red+green+blue |
  |  8 | 10 |            5 |    red+blue    |
  | 10 | 14 |            3 |       red      |
  </code></pre>
  
  <p>Any ideas if sqlite can do that? Perhaps by creating interim tables?</p>