I have two tables:
VOTES
ID | YEARMONTH | VOTES
========================
1 | 201101 | 23
1 | 201102 | 12
1 | 201103 | 12
2 | 201101 | 15
3 | 201102 | 1
4 | 201102 | 17
LECTURES
ID | YEARMONTH | LECTURES
========================
1 | 201101 | 1
2 | 201101 | 2
3 | 201102 | 5
Assuming that an ID can have no rows for each of the tables for a given yearmonth (either lectures or votes), I need to list the results so I can show them in a graph.
If for a yearmonth a result is missing on the other table, I need to display zero.
So that the result should look like this:
ID | YEARMONTH | VOTES | LECTURES
==================================
1 | 201101 | 23 | 1
1 | 201102 | 12 | 0
1 | 201103 | 12 | 0
But of course, if VOTES were missing where LECTURES are not missing, I would need to display a 0 there.