fiyatlı olanda buydu sanırım
SELECT
ITM.CODE AS KODU,
ITM.STGRPCODE AS Kodu,
ITM.NAME AS Adı,
onhand AS [Fiili Stok],
tot.ONHAND-ACTSORDER AS [Gerçek Stok],
(SELECT TOP 1 PRICE FROM LG_008_06_STLINE WHERE STOCKREF = ITM.LOGICALREF AND (TRCODE = 1 OR (TRCODE = 14 AND BILLED = 0)) AND LPRODSTAT = 0 AND LINETYPE = 0 ORDER BY DATE_ DESC) AS [Son Alış]
FROM
LG_008_06_GNTOTST TOT INNER JOIN
LG_008_ITEMS ITM ON ITM.LOGICALREF = TOT.STOCKREF
WHERE
(TOT.INVENNO =0) AND (ITM.ACTIVE = 0) ORDER BY ITM.NAME