Click here to Skip to main content
15,885,998 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
SQL
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
Posted
Updated 13-Oct-15 19:39pm
v2
Comments
Naveen.Sanagasetti 8-Oct-15 2:40am    
This is very hard to give solution if you provide the query like this, because we don't know about your table structure and data. I request you to please provide some sample data and table design then provide the details of your requirement. So, that we will help you better.

To do it you sum(colomn) and group all other columns at end of query. Or do other aggregates on the columns and no need to group them.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900