Need some help joining these two tables
I have two views that looks like this
view1 view2
+------+--------+ +------+--------+
| code | SUM(*) | | code | SUM(*) |
+------+--------+ +------+--------+
| AAA | 4 | | AAA | 4 |
| BBB | 3 | | CCC | 1 |
+------+--------+ +------+--------+
I want to join them into a table that looks like this
+------+--------+
| code | SUM(*) |
+------+--------+
| AAA | 4 |
| BBB | 3 |
| CCC | 1 |
+------+--------+
I have tried, but only failed..
For your first result, the answers posted using
unionwill do the trick:However, given the fact that one of your columns is a sum, this seems unlikely to be what you actually want.
For your second result (where the values are added), you’ll need to use a
unionand a subquery: