Merhaba,
1) LG_777_CLCARD.LOGICALREF = LG_777_04_STFICHE.RECVR
2) LG_777_CLCARD.LOGICALREF = LG_777_04_STFICHE.CLIENTREF
İkisini birlikte yazdığımda hata veriyor.
İki fiş türü var biri Toptan Satış İrslaiyesi, diğeri Konsinye giriş irslaiyesi,
konsinye giriş irsaliyesindeki recvr aslında müşyeri kodu, ben recvr olan yere müşteri kodu yazmazını istiyorum,
kodu ünvanı recvr
00493018 ŞEVİKOĞLU GIDA TİC. LTD. ŞTİ. (GÜNLÜKBAŞI) 0
00494663 ÜMİT BAYSAL BAYSAL MARKET 0
15036990 UNİLEVER SANAYİ VE TİCARET TÜRK AŞ. 342
Sorgu şu şekilde
SELECT LG_777_04_STFICHE.TRCODE , LG_777_CLCARD.CODE , LG_777_04_STFICHE.RECVREF, LG_777_CLCARD.DEFINITION_ , Sum(CASE LG_777_04_STFICHE.TRCODE WHEN 3 THEN -1 WHEN 5 THEN -1 WHEN 8 THEN 1 WHEN 10 THEN 1 ELSE 0 END*PE_777_04_Mamul.Hacim*LG_777_04_STLINE.AMOUNT*LG_777_04_STLINE.UINFO2) , LG_777_CLCARD.SALESBRWS
FROM UNITY.dbo.LG_777_04_STFICHE LG_777_04_STFICHE, UNITY.dbo.LG_777_04_STLINE LG_777_04_STLINE, UNITY.dbo.LG_777_CLCARD LG_777_CLCARD, UNITY.dbo.LG_777_ITEMS LG_777_ITEMS, UNITY.dbo.LG_SLSMAN LG_SLSMAN, UNITY.dbo.PE_777_04_Mamul PE_777_04_Mamul, UNITY.dbo.PE_777_04_MamulBirim PE_777_04_MamulBirim, UNITY.dbo.PE_777_04_Marka PE_777_04_Marka, UNITY.dbo.PE_777_04_MarkaKategori PE_777_04_MarkaKategori
WHERE LG_777_CLCARD.LOGICALREF = LG_777_04_STLINE.CLIENTREF AND LG_777_ITEMS.LOGICALREF = LG_777_04_STLINE.STOCKREF AND LG_777_04_STLINE.SALESMANREF = LG_SLSMAN.LOGICALREF AND LG_777_ITEMS.LOGICALREF = PE_777_04_MamulBirim.ITEMREF AND PE_777_04_MamulBirim.ITEMREF = PE_777_04_Mamul.MamulRef AND PE_777_04_Mamul.MarkaKodu = PE_777_04_Marka.MarkaKodu AND PE_777_04_Mamul.MarkaKategoriKodu = PE_777_04_MarkaKategori.Kodu AND LG_777_04_STFICHE.LOGICALREF = LG_777_04_STLINE.STFICHEREF
GROUP BY LG_777_04_STFICHE.TRCODE, LG_777_CLCARD.CODE, LG_777_04_STFICHE.RECVREF, LG_777_CLCARD.DEFINITION_, LG_777_CLCARD.SALESBRWS, LG_777_04_STFICHE.BRANCH, LG_777_04_STFICHE.CANCELLED, LG_777_04_STFICHE.DATE_
HAVING (LG_777_04_STFICHE.BRANCH=465) AND (LG_777_04_STFICHE.TRCODE In (3,5,8,10)) AND (LG_777_04_STFICHE.CANCELLED=0) AND (LG_777_04_STFICHE.DATE_ Between {ts '2012-01-01 00:00:00'} And {ts '2012-01-31 00:00:00'})
ORDER BY LG_777_CLCARD.CODE