sql query to calculate the stock of each product from table of sells and table the purchases

I have two tables :

First table is called tbpurchase for purchased items looks like:

|id | Product | quantity |
+---+---------+----------+
 1  | Hp i5   | 20
 2  | Acer i7 | 10

The second table is for sales for sold items and looks like

|id | Product | quantity |
+---+---------+----------+
 1  | Hp i5   | 5
 2  | Acer i7 | 2

I don't know how to query the stock which still available for each product

Thanks in advance

I would really appreciate your effort



Read more here: https://stackoverflow.com/questions/65709962/sql-query-to-calculate-the-stock-of-each-product-from-table-of-sells-and-table-t

Content Attribution

This content was originally published by splintos at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: