SELECT ProductCode, InitialStock, (SELECT Quantity FROM NewInvoice_2 WHERE NewInvoice_2.Item=Product.ProductCode) AS StockRemaining FROM Product;
PoductId ProductName ProductCode InitialStock 1 product1 P101 10 2 product2 p102 15
InvoiceNo ProductCode Qty Inv-111 P101 3 Inv-112 P102 5 Inv-113 P102 3
ProductCode InitialStock StockRemaining P101 10 7 P102 15 7
select p.productcode, initialstock, initialstock - sum(qty) AS stockremaining from product p join invoice i on p.productcode = i.productcode group by p.productcode, initialstock
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)