İşte bu kadar
Kolay gelsin.
------------------------------
SELECT HAREKET.LOGICALREF,
FATURA.FICHENO,
CARI.CODE,
CARI.DEFINITION_,
MALZEME.CODE AS KODU,
MALZEME.NAME AS ACIKLAMASI,
(SELECT MALZEME.CODE
FROM LG_001_ITEMS MALZEME
WHERE MALZEME.LOGICALREF=HAREKET.STOCKREF
AND HAREKET.TRCODE IN ('7','8')) AS MALZEME,
HAREKET.AMOUNT AS ADET,
HAREKET.VATMATRAH AS TUTAR,
CONVERT (NUMERIC (18,2), (100*((HAREKET.PRICE*HAREKET.AMOUNT)-HAREKET.VATMATRAH))/HAREKET.PRICE*HAREKET.AMOUNT) AS INDIRIM -- FORMÜL BU ŞEKİLDE OLMALI
FROM LG_001_01_STLINE HAREKET (NOLOCK)
LEFT OUTER JOIN LG_001_ITEMS MALZEME
WITH(NOLOCK) ON HAREKET.STOCKREF=MALZEME.LOGICALREF
LEFT OUTER JOIN LG_001_CLCARD CARI
WITH(NOLOCK) ON HAREKET.CLIENTREF=CARI.LOGICALREF
LEFT OUTER JOIN LG_001_01_INVOICE FATURA
WITH(NOLOCK) ON HAREKET.INVOICEREF=FATURA.LOGICALREF
WHERE HAREKET.DATE_ BETWEEN'01.01.2008' AND '12.31.2008'
AND HAREKET.TRCODE IN ('7','8')
AND HAREKET.LINETYPE IN (0)
-- AND MALZEME.CODE LIKE 'DEF%' -- İŞ TE BURADAN KRITERİNİ VERECEKSİN
ORDER BY CARI.CODE,
FATURA.FICHENO,
HAREKET.INVOICELNNO