title: MySQL how to add/subtract two columns together based on date?
body: <p>I have two select statements that take values from two different tables.
  the select statements look something like this</p>
  
  <pre><code>SELECT year(timestamp) y, month(timestamp) m, count(id) c
  FROM table
  WHERE clause="foo"
  GROUP BY year(timestamp), month(timestamp)
  </code></pre>
  
  <p>which returns something like</p>
  
  <pre><code>|-y--|-m|c|
  |2013|01|9|
  |2013|02|9|
  |2013|03|9|
  |2013|04|9|
  </code></pre>
  
  <p>.</p>
  
  <pre><code>SELECT year(timestamp) y, month(timestamp) m, count(id) c
  FROM table2
  WHERE clause="foo"
  GROUP BY year(timestamp), month(timestamp)
  </code></pre>
  
  <p>which returns something like</p>
  
  <pre><code>|-y--|-m|c|
  |2013|01|1|
  |2013|03|1|
  |2013|04|1|
  </code></pre>
  
  <p>What I'm looking for is joining the two tables based on the timestamp, and subtract the second table from the first. So it should look like:</p>
  
  <pre><code>|-y--|-m|c|
  |2013|01|8|
  |2013|02|9|
  |2013|03|8|
  |2013|04|8|
  </code></pre>
  
  <p>thanks!</p>