title: Calculate the difference of the sums of different rows
body: <p>I would like to calculate the difference between two sums from different tables
  my query:</p>
  
  <pre><code>SELECT a.id AS id, SUM(a.amount) AS total
      FROM atable a
      LEFT JOIN btable b
      ON a.id = b.id
      WHERE a.start_date BETWEEN a.start_date AND '1996-01-01'
      GROUP BY a.id
      ORDER BY a.id;
  </code></pre>
  
  <p>the result of the 1st query is this:</p>
  
  <pre><code>     id |  total
  --------+----------
        1 |   999
        2 |   888
        3 |   999
        4 |   111
  </code></pre>
  
  <p>my 2nd query:</p>
  
  <pre><code>SELECT b.id AS id, SUM(b.amount) AS total
      FROM atable a
      LEFT JOIN btable b
      ON a.id = b.id
      WHERE a.end_date BETWEEN a.end_date AND '1996-01-01'
      GROUP BY b.id
      ORDER BY b.id;
  </code></pre>
  
  <p>the result of the second query looks like this:</p>
  
  <pre><code>     id |  total
  --------+----------
        1 |   999
        2 |   866
        3 |   330
        4 |    90
  </code></pre>
  
  <p>I would want to combine the two queries in one to know the difference between the total columns such that the output will look like:</p>
  
  <pre><code>     id |  diff
  --------+----------
        1 |     0
        2 |    22
        3 |   660
        4 |    21
  </code></pre>