Say I have table 1, Table 2 with common fields "Level_Code" and Amount.
"Level_Code" can be 1,2,3
Each "Level_Code" has amounts assigned to it.
I'd like to query the database so that it returns
1 XXXX
2 XXXX
3 XXXX
That is, adds all the amount under the codes and display it.
My attempt was the following statements.
SELECT Level_Code, sum(Amount)
FROM Table 1
GROUP BY Level_Code
UNION SELECT Level_Code, sum(Amount)
FROM Table 2
GROUP BY Level_Code
The output is like this.
1 XXX
1 XXX
2 XX
2 XXX
3 XX
3 XXX
It seems to show the table Level_Codes saperately. How can i query to make it add up Amount for each code and show only
1 XXX
2 XXX
3 XXX
Thank you