title: oracle sql multiple sum function
body: <p>I have a query with multiple <code>SUM</code>s that is giving me higher values than I expect. If I cut the query down to just one <code>SUM</code> everything works fine, but as soon as I add the other <code>SUM</code>s I get incorrect values. I've tried looking online and tried different approaches including changing the <code>JOIN</code>s and nested <code>SELECT</code>s, but still no luck. All help will be appreciated.</p>
  
  <pre><code>SELECT
      A.WR_NO WORK_ORDER, A.WR_TYPE_CODE WR_TYPE, B.NAME PLANNER, A.SCHEDULING_POLYGON_CODE AREA, A.FINAL_CLOSE_DATE COMPLETION_DATE, C.ACTUAL_ITEM_AMT EST_ENG,
      SUM(D.AFTER_COND_FCT_AMT) EST_CREW, SUM(E.AFTER_COND_FCT_AMT) ASB_CREW, SUM(F.AFTER_COND_FCT_AMT) EST_CONTR, SUM(G.AFTER_COND_FCT_AMT) ASB_CONTR
  FROM
      WORK_REQUEST A, CC.ALL_PEOPLE B, WR_CONTRIBUTION_VOUCHER C, WR_COST_ESTIMATE D, WR_COST_ESTIMATE E, WR_COST_ESTIMATE F, WR_COST_ESTIMATE G
  WHERE
      (A.FINAL_CLOSE_DATE BETWEEN TO_DATE ('10/01/2012','MM/DD/YYYY') AND TO_DATE ('10/04/2012','MM/DD/YYYY'))
      AND A.ENTRY_PERSON_NO = B.PERSON_NO(+)
      AND A.WR_NO = C.WR_NO(+)
      AND A.WR_NO = D.WR_NO(+)
      AND A.WR_NO = E.WR_NO(+)
      AND A.WR_NO = F.WR_NO(+)
      AND A.WR_NO = G.WR_NO(+)
      AND (C.VOUCHER_CNTRB_TYPE_CODE(+) = 'ENGT')
      AND (D.COST_TYPE_CODE(+) = 'LAB' AND D.DESIGN_ASBUILT_DA(+) = 'D' AND   D.PROVIDER(+) = 'CO')
      AND (E.COST_TYPE_CODE(+) = 'LAB' AND E.DESIGN_ASBUILT_DA(+) = 'A' AND   E.PROVIDER(+) = 'CO')
      AND (F.COST_TYPE_CODE(+) = 'LAB' AND F.DESIGN_ASBUILT_DA(+) = 'F' AND   F.PROVIDER(+) = 'CN')
      AND (G.COST_TYPE_CODE(+) = 'LAB' AND G.DESIGN_ASBUILT_DA(+) = 'G' AND   G.PROVIDER(+) = 'CN')
  GROUP BY
      A.WR_NO, A.WR_TYPE_CODE, B.NAME, A.SCHEDULING_POLYGON_CODE, A.FINAL_CLOSE_DATE,     C.ACTUAL_ITEM_AMT
  ORDER BY 1
  </code></pre>