Onu da ben ekleyeyim bari
SELECT TOP 100 PERCENT ITM.CODE AS KODU, ITM.STGRPCODE AS Kodu, ITM.NAME AS Adı, TOT.ONHAND AS [Fiili Stok],
TOT.ONHAND - TOT.ACTSORDER AS [Gerçek Stok],
(SELECT TOP 1 PRICE
FROM LG_001_01_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ış],
(SELECT TOP 1 PRICE
FROM LG_001_PRCLIST
WHERE CARDREF = ITM.LOGICALREF AND PTYPE = 2) AS [Satış Fiyatı]
FROM dbo.LG_001_01_GNTOTST TOT INNER JOIN
dbo.LG_001_ITEMS ITM ON ITM.LOGICALREF = TOT.STOCKREF
WHERE (ITM.ACTIVE = 0) AND (TOT.INVENNO = 0)
ORDER BY ITM.NAME