I have two select statements that take values from two different tables. the select statements look something like this
SELECT year(timestamp) y, month(timestamp) m, count(id) c
FROM table
WHERE clause="foo"
GROUP BY year(timestamp), month(timestamp)
which returns something like
|-y--|-m|c|
|2013|01|9|
|2013|02|9|
|2013|03|9|
|2013|04|9|
.
SELECT year(timestamp) y, month(timestamp) m, count(id) c
FROM table2
WHERE clause="foo"
GROUP BY year(timestamp), month(timestamp)
which returns something like
|-y--|-m|c|
|2013|01|1|
|2013|03|1|
|2013|04|1|
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:
|-y--|-m|c|
|2013|01|8|
|2013|02|9|
|2013|03|8|
|2013|04|8|
thanks!