Merhaba,
Öncelikli olarak aşağıdaki query ile bir tane view oluşturacağız
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW MALZEME_RAPORU WITH ENCRYPTION AS
SELECT ITEMS.CODE AS Stok_Kodu,
ITEMS.NAME AS Stok_Aciklamasi,
TOT.PURAMNT AS Giren
FROM LG_102_ITEMS ITEMS
LEFT OUTER JOIN LG_102_02_GNTOTSAT TOT ON
TOT.STOCKREF = ITEMS.LOGICALREF
WHERE (ITEMS.ACTIVE = 0) AND (ITEMS.CODE LIKE 'A%') AND (TOT.INVENNO = 0)
UNION ALL
SELECT ITEMS.CODE AS Stok_Kodu,
ITEMS.NAME AS Stok_Aciklamasi,
TOT.PURAMNT AS Giren
FROM LG_102_ITEMS ITEMS
LEFT OUTER JOIN LG_102_03_GNTOTSAT TOT ON
TOT.STOCKREF = ITEMS.LOGICALREF
WHERE (ITEMS.ACTIVE = 0) AND (ITEMS.CODE LIKE 'A%') AND (TOT.INVENNO = 0)
UNION ALL
SELECT ITEMS.CODE AS Stok_Kodu,
ITEMS.NAME AS Stok_Aciklamasi,
TOT.PURAMNT AS Giren
FROM LG_102_ITEMS ITEMS
LEFT OUTER JOIN LG_102_04_GNTOTSAT TOT ON
TOT.STOCKREF = ITEMS.LOGICALREF
WHERE (ITEMS.ACTIVE = 0) AND (ITEMS.CODE LIKE 'A%') AND (TOT.INVENNO = 0)
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
Daha sonra aşağıdaki query ile de istemiş oluğun raporu alabilirsin.
SELECT Stok_Kodu,
Stok_Aciklamasi,
SUM (Giren) AS Giren
WHERE MALZEME_RAPORU
GROUP BY Stok_Kodu,
Stok_Aciklamasi
işini görür inşallah
Kolay gelsin