CariHesapSağTuş_BorçtakipToplamları_SQL_Sorgusu
SET ROWCOUNT 0 SELECT PTRNS.TRCURR, SUM((PTRNS.TOTAL - 0)*(1- PTRNS.SIGN)) AS A1, SUM((PTRNS.TOTAL - PTRNS.PAID) * PTRNS.SIGN) AS A2, SUM(PTRNS.PAID*(1- PTRNS.SIGN)) AS A3, SUM(PTRNS.PAID * PTRNS.SIGN) AS A4, SUM((PTRNS.TOTAL - PTRNS.PAID)*(1- PTRNS.SIGN)* PTRNS.PAIDINCASH) AS A5, SUM((PTRNS.TOTAL - PTRNS.PAID) * PTRNS.SIGN*PTRNS.PAIDINCASH) AS A6 FROM LG_106_01_PAYTRANS PTRNS WITH(NOLOCK, INDEX = I106_01_PAYTRANS_I2) WHERE (PTRNS.CARDREF = 3052) AND (PTRNS.DATE_ >= CONVERT(dateTime, '1-1-2012', 101)) AND (PTRNS.DATE_ <= CONVERT(dateTime, '12-31-2017', 101)) AND (PTRNS.CANCELLED = 0 ) GROUP BY PTRNS.TRCURR