This seems so simple, but I can't seem to figure out how to do it. I have two data sets:
SET1
DATE | TOTAL1 | TOTAL2 | TOTAL3
1 Jun 2013 | 0 | 0 | 5
2 Jun 2013 | 0 | 0 | 12
3 Jun 2013 | 0 | 0 | 34
4 Jun 2013 | 0 | 0 | 50
SET2
DATE | TOTAL1 | TOTAL2 | TOTAL3
1 Jun 2013 | 1 | 2 | 0
2 Jun 2013 | 4 | 12 | 0
3 Jun 2013 | 5 | 12 | 0
4 Jun 2013 | 6 | 10 | 0
I want to create a third dataset the merges these two sets into the following:
SET3
DATE | TOTAL1 | TOTAL2 | TOTAL3
1 Jun 2013 | 1 | 2 | 5
2 Jun 2013 | 4 | 12 | 12
3 Jun 2013 | 5 | 12 | 34
4 Jun 2013 | 6 | 10 | 50
Joining the tables does not work. I need to join them in a way that will add the totals if the dates match up. Any idea how to do this?
date. It's also unclear why your columns are namedtotal. I can't see the SQL you have tried (even if it does not work), nor the Postgres version you are working with ... Please edit your question to make it clear.