The below query will give you the received and sold inventory values with including quantity received & sold, quantity received value & sold value based on the vendors.
SELECT Vendor
,ITEMNMBR
,[Received QTY]
,[Sold QTY]
,([Received QTY] – [Sold QTY]) [Remaining QTY]
,[Purchase Value]
,[Sold Value]
,([Purchase Value] – [Sold Value]) [Remaining Inventory Value]
FROM (
SELECT VENDORID AS Vendor
,ITEMNMBR
,(
SELECT SUM(QTYRECVD)
FROM IV10200
WHERE ITEMNMBR = A.ITEMNMBR
AND PCHSRCTY = 5
AND VENDORID = A.VENDORID
) AS [Received QTY]
,(
SELECT SUM(QTYSOLD)
FROM IV10200
WHERE ITEMNMBR = A.ITEMNMBR
AND PCHSRCTY = 5
AND VENDORID = A.VENDORID
) AS [Sold QTY]
,(
SELECT SUM(QTYRECVD * UNITCOST)
FROM IV10200
WHERE ITEMNMBR = A.ITEMNMBR
AND PCHSRCTY = 5
AND VENDORID = A.VENDORID
) AS [Purchase Value]
,(
SELECT SUM(QTYSOLD * UNITCOST)
FROM IV10200
WHERE ITEMNMBR = A.ITEMNMBR
AND PCHSRCTY = 5
AND VENDORID = A.VENDORID
) AS [Sold Value]
FROM IV10200 A
WHERE A.VENDORID <> ”
AND PCHSRCTY = 5
GROUP BY A.VENDORID
,A.ITEMNMBR
) PurchaseByVendor
Hope this helps!!!