I have a table named stock
:
name stock
------------
a 100
b 200
c 50
and a sales
table
name sale
--------------------
a 30
c 20
d 30
The result should be:
name stock
-----------------
a 70
b 200
c 20
d -30
Please tell me the sqlite query for this.
My query:
select a.name, a.stock - b.sales as stock
from stock as a
inner join Sale as b on a.name = b.name
but how to get those name which doesn't exists in stock but exists in sales?