Hi Dear SQL Experts,
May I humbly ask your help on how to compute the ending inventory of each product to complete my inventory program please.
I want to calculate the remaining qty of each product using SQL sirs,
Is there any ways to attached my DB design here
My formula is : ENDING INVENTORY = (BEGINNING INVENTORY + PURCHASES) - SALES + SALES RETURN - STOCKS RETURN
Thank you very much for your help
Here are my tables
ITEMS
Itemcode
Description
BEGINNING_INVENTORY
itemcode
Qty
Transdate
PURCHASES HEADER
Ponumber
Suppliercode
Refno
Transdate
Statuscode
PURCHASE DETAIL
ponumber
Itemcode
Qty
SALED ORDER HEADER
Sonumber
Customercode
Refno
Transdate
Statuscode
SALES ORDER DETAIL
Sonumber
Itemcode
Qty
SALES RETURN HEADER
salesreturnnumber
Customercode
Refno
Transdate
Statuscode
SALES RETURN DETAIL
Salesreturnnumber
Itemcode
Qty
STOCK RETURN HEADER
IDnumber
Suppliercode
Refno
Transdate
Statuscode
STOCK RETURN DETAIL
IDnumber
Itemcode
Qty
EXPECTED OUTPUT
ITEM CODE DESCRIPTION BEGINNING PURCHASES SALES SALESRETURN STOCKRETURN ENDING
regards
leo