SET ROWCOUNT 0
SELECT GLACC.CODE,
GLACC.DEFINITION_,
SUM(GLSUM.DEBIT) DEBIT,SUM(GLSUM.CREDIT) CREDIT,SUM(GLSUM.DEBIT-GLSUM.CREDIT) BAKIYE
FROM
LV_101_01_EMUHTOT GLSUM WITH(NOLOCK) LEFT OUTER JOIN LG_101_EMUHACC GLACC WITH(NOLOCK) ON (GLSUM.ACCOUNTREF = GLACC.LOGICALREF)
WHERE
((GLSUM.MONTH_ <> -1) OR (GLSUM.YEAR_ = 2019)) AND ((GLSUM.MONTH_ <> -2) OR (GLSUM.YEAR_ = 2019)) AND (( (GLSUM.YEAR_ = 2019) AND( (GLSUM.MONTH_ >= 1) OR (GLSUM.MONTH_ = -1) ) ) OR ( (GLSUM.YEAR_ = 2019) AND(GLSUM.MONTH_ <= 12) )) AND ((GLSUM.TOTTYPE <> 8) OR (GLSUM.CURRTYP > 0) ) AND (GLSUM.TOTTYPE IN (1)) AND ((GLSUM.TOTTYPE <> 8) OR (GLSUM.CURRTYP = GLACC.CCURRENCY))
GROUP BY
GLACC.CODE,DEFINITION_,GLSUM.ACCOUNTREF,GLSUM.TOTTYPE
ORDER BY CODE
SELECT GLACC.CODE,
GLACC.DEFINITION_,
SUM(GLSUM.DEBIT) DEBIT,SUM(GLSUM.CREDIT) CREDIT,SUM(GLSUM.DEBIT-GLSUM.CREDIT) BAKIYE
FROM
LV_101_01_EMUHTOT GLSUM WITH(NOLOCK) LEFT OUTER JOIN LG_101_EMUHACC GLACC WITH(NOLOCK) ON (GLSUM.ACCOUNTREF = GLACC.LOGICALREF)
WHERE
((GLSUM.MONTH_ <> -1) OR (GLSUM.YEAR_ = 2019)) AND ((GLSUM.MONTH_ <> -2) OR (GLSUM.YEAR_ = 2019)) AND (( (GLSUM.YEAR_ = 2019) AND( (GLSUM.MONTH_ >= 1) OR (GLSUM.MONTH_ = -1) ) ) OR ( (GLSUM.YEAR_ = 2019) AND(GLSUM.MONTH_ <= 12) )) AND ((GLSUM.TOTTYPE <> 8) OR (GLSUM.CURRTYP > 0) ) AND (GLSUM.TOTTYPE IN (1)) AND ((GLSUM.TOTTYPE <> 8) OR (GLSUM.CURRTYP = GLACC.CCURRENCY))
GROUP BY
GLACC.CODE,DEFINITION_,GLSUM.ACCOUNTREF,GLSUM.TOTTYPE
ORDER BY CODE