SELECT
A.CODE AS Kodu, A.NAME AS ACIKLAMA,
CONVERT( VARCHAR (10), B.LASTTRDATE,104) AS SHTarihi,
ISNULL(SUM(CASE WHEN B .INVENNO = 0 THEN B .ONHAND - B .RESERVED END), 0) AS DEPO,
--CONVERT(VARCHAR(10),GETDATE(),104) AS BUGUN,
DATEDIFF( DAY, B.LASTTRDATE,GETDATE()) AS [HAREKETSİZ GÜN SAYISI]
--(CONVERT( VARCHAR (10), B.LASTTRDATE,104) - CONVERT(VARCHAR(10),GETDATE(),104)) AS TARİH
--ISNULL(SUM(CASE WHEN B .INVENNO = 1 THEN B .ONHAND END), 0) AS AMBAR
FROM LG_115_ITEMS AS A INNER JOIN
LV_115_01_GNTOTST AS B ON A.LOGICALREF = B.STOCKREF
GROUP BY A.CODE, A.NAME, B.LASTTRDATE
ORDER BY Kodu, SHTarihi
Cevaplar için teşekkür ederim üstadlarım.