SELECT EMC.CODE, EMC.DEFINITION_,
Sum (EML.DEBIT), Sum(EML.CREDIT), Sum(EML.DEBIT) - Sum(EML.CREDIT)
FROM LG_500_01_EMFLINE EML,
LG_500_EMUHACC EMC
WHERE ((LEVEL_ = 0 And SUBSTRING(EML.ACCOUNTCODE, 1, 3) = EMC.CODE) Or (LEVEL_ = 1 And SUBSTRING(EML.ACCOUNTCODE, 1, 6) = EMC.CODE) Or (LEVEL_ = 2 And SUBSTRING(EML.ACCOUNTCODE, 1, 15) = EMC.CODE))
AND (EML.DATE_ BETWEEN '1-1-2010' AND '12-31-2010')
--AND EMC.CODE LIKE '120%'
GROUP BY EMC.CODE, EMC.DEFINITION_
ORDER BY EMC.CODE
Firma No,Dönem tarih değiştirmeyi unutmayın
Kod mantığı 100.01.001 göre 'dir.