I've got two mySQL
tables, Table A and B. I need to get an output like in Table 3.
Below mentioned is the code I tried with Full Join and does not give me the intended result. Much appreciate your help..
SELECT DISTINCT(Table_A.Code) as 'Code', SUM(Table_A.Qty_On_Hand) as 'On Hand Qty', SUM(Table_B.Counted_Qty) as 'Counted Qty'
FULL JOIN Table_B ON Table_A.Code = Table_B.Code
FROM Table_A
Table A
Code | On Hand Qty |
---|---|
A | 20 |
B | 10 |
B | 20 |
B | 50 |
C | 60 |
Table B
Code | Counted Qty |
---|---|
A | 10 |
B | 0 |
C | 30 |
B | 0 |
C | 10 |
Out put required:
Code | On Hand Qty | Counted Qty |
---|---|---|
A | 20 | 10 |
B | 80 | 0 |
C | 60 | 40 |