Sum column in one table with different criteria
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Sum column in one table with different criteria

  1. #1
    Join Date
    Apr 2010
    Posts
    2

    Sum column in one table with different criteria

    Hi,

    Could anyone advise how to select in one query instead of two??

    SELECT T0.DocDate, SUM (T1.[LineTotal]) as "APBASE", ROUND((sUM(T1.LineTotal)*0.07),2) AS "APGST"
    FROM OPCH T0 INNER JOIN PCH1 T1
    ON T0.DocEntry = T1.DocEntry and T1.ItemCode NOT IN ('CARRY FEE', 'carry fee (packing)', 'LABOUR', 'CUSTOMS', 'TRANSPORT')
    AND T0.U_PermitNos = 'IG4555' AND T0.DocType = 'I' group by t0.docdate



    SELECT T1.LineTotal, T0.U_YS_GSTBaseAmt FROM OPCH T0 INNER JOIN PCH1 T1
    ON T0.DocEntry = T1.DocEntry
    AND T0.U_PermitNos = 'IG4555' AND T0.DocType = 's'

  2. #2
    Join Date
    Apr 2010
    Posts
    2

    Re: Sum column in one table with different criteria

    Hi, there are some changes to the codes

    SELECT T0.DocDate, SUM (T1.[LineTotal]) as "APBASE", ROUND((sUM(T1.LineTotal)*0.07),2) AS "APGST"
    FROM OPCH T0 INNER JOIN PCH1 T1
    ON T0.DocEntry = T1.DocEntry and T1.ItemCode NOT IN ('CARRY FEE', 'carry fee (packing)', 'LABOUR', 'CUSTOMS', 'TRANSPORT')
    AND T0.DocType = 'I' group by t0.U_permitnos

    The above script will sum up all the document grp by the permitnos.....


    SELECT T1.LineTotal, T0.U_YS_GSTBaseAmt FROM OPCH T0 INNER JOIN PCH1 T1
    ON T0.DocEntry = T1.DocEntry
    AND T0.DocType = 's'

    For the above script, it only have one document per PermitNos....

    Kindly advise...thanks...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center