I Have The Following Query, I Want To Sum Of E.Value (C.Idclient,Con.Code As "Countrycode" Wise Other Selection Field Is Individual). How Can Do This?
Query:
SELECT C.IDCLIENT, D.DOCNO, E.NO, D.OPDATE, E.VALUEDATE, E.DEBITENTCODE, E.DEBITACCOUNT, E.CREDITACCOUNT, E.VALUE, E.SHORTREMARK, ATM.PAN, ATM.TERM,
ATM.DEVICE, ATM.ISSCODE, ATM.FICODE, ATM.ENTTYPE, ATM.CURRENCY, ATM.TERMLOCATION, CON.NAME, TP.CODE,CON.CODE AS "CountryCode",TP.NAME AS "CardTypeName"
FROM (TDOCUMENT D JOIN TENTRY E ON D.DOCNO = E.DOCNO AND D.BRANCH = E.BRANCH JOIN TACCOUNT A ON A.BRANCH=E.BRANCH AND A.ACCOUNTNO=E.CREDITACCOUNT
JOIN TATMEXT ATM ON D.DOCNO = ATM.DOCNO AND D.BRANCH = ATM.BRANCH JOIN A4M.TREFERENCECOUNTRY CON ON ATM.ACQCOUNTRY = CON.CODE AND CON.BRANCH = ATM.BRANCH
JOIN TCARD C ON C.BRANCH = ATM.BRANCH AND ATM.PAN = C.PAN
JOIN A4M.TREFERENCECARDPRODUCT TP ON ATM.PAN LIKE TP.PREFIX||'%' AND CON.BRANCH = TP.BRANCH)
WHERE D.BRANCH = 7060 AND ATM.ACQCOUNTRY <> 50
AND TP.CODE IN ( 21,28,29,30,41,42,102,103,104,105) AND D.NEWDOCNO IS NULL
AND ATM.ISSCODE NOT IN (401,513,527) AND ATM.FICODE NOT IN (401,513,527) AND ATM.ENTTYPE <> 'R' AND ATM.ENTCODE = 10 AND ATM.FICODE <> 33
AND D.OPDATE BETWEEN '06-OCT-2015' AND '07-OCT-2015' AND E.DEBITENTCODE = 45 AND E.NO = 1 ORDER BY CON.NAME,D.OPDATE,D.DOCNO,E.NO