How can I subtract the quantities in table2 from table1?
I'm using SQL Server 2014.
Table1
P_ID name quantity
1 carrot 100
2 eggplant 100
3 Avocado 100
4 Cabbage 100
5 peppers 100
Table2
P_ID name quantity
1 carrot 3
2 eggplant 12
5 peppers 7
2 eggplant 8
1 carrot 25
5 peppers 13
The final result should be like this:
Table1
P_ID name quantity
1 a 73
2 b 80
3 c 100
4 d 100
5 e 80
How can I do this? Is this even possible?