SELECT STOK.STOKID, STOKGRUP.ADI AS GADI, SFIYAT1,STOK.GRUP, STOK.KODU, STOK.ADI, STOK.SSATICI, STOK.SALISFIYAT, STOK.SFATURANO, STOK.SFATTARIHI, ((SFIYAT1)*(100-STOK.ALISIND)/100) AS ALIS, ((SFIYAT1)*(100-STOK.EK1)/100) AS AALIS, SKARY,SATISIND, ((SFIYAT1+NAKLIYE)*(100-SATISIND)/100) AS SATIS, SATISKDV,SATIS*(100+SATISKDV)/100 AS KDVLISATIS, STOK.SDOVIZ, (SELECT TOP 1 KUR2 FROM DOVIZISL WHERE DOVIZISL.KODU=STOK.SDOVIZ ORDER BY TARIH DESC) AS SATISKUR, KDVLISATIS*SATISKUR AS SATISTL, (SELECT SUM(ADET) FROM FATISL WHERE FATISL.STOKID=STOK.STOKID) AS BAKIYE, STOK.BIRIM AS ABIRIM, BAKIYE*KATSAYI2 AS BAKIYE2, STOK.BIRIM2, STOK.KATSAYI2 AS KATSAYI, (SATIS-ALIS)*BAKIYE AS KAR, (SELECT TOP 1 KUR2 FROM DOVIZISL WHERE DOVIZISL.KODU=STOK.SDOVIZ ORDER BY TARIH DESC) AS MBKUR, CARI.KODU AS SATICI, STOK.EK1 FROM (STOKGRUP RIGHT JOIN STOK ON STOKGRUP.KODU = STOK.GRUP) LEFT JOIN CARI ON STOK.SSATICI = CARI.CARIID WHERE SSATICI=11 ORDER BY STOK.KODU
