Rica Ederim son olarak kodda iptal edilen kayıtlarıda kapsıyor bunun için aşağıdaki şekilde kodu revize ederseniz iptal olanlar gelmez.
SELECT ITM.CODE AS Kodu, ITM.NAME AS Adı, TOT.ONHAND AS [Eldeki Miktar],
(SELECT TOP 1 PRICE
FROM LG_006_01_STLINE
WHERE STOCKREF = ITM.LOGICALREF AND (TRCODE = 1 OR
(TRCODE = 14 AND BILLED = 0)) AND LPRODSTAT = 0 AND LINETYPE = 0 AND CANCELLED=0
ORDER BY DATE_ DESC) AS [Son Alış],
(SELECT TOP 1 PRICE
FROM LG_006_01_STLINE
WHERE STOCKREF = ITM.LOGICALREF AND TRCODE IN(7,8) AND LPRODSTAT = 0 AND LINETYPE = 0 AND CANCELLED=0
ORDER BY DATE_ DESC) AS [Son Satış]
FROM LG_006_01_GNTOTST TOT INNER JOIN
LG_006_ITEMS ITM ON ITM.LOGICALREF = TOT.STOCKREF
WHERE (TOT.INVENNO = - 1) AND (ITM.ACTIVE = 0)