title: MySQL Multiple Table Joins incorrect summation
body: <p>I'm trying to join and sum three tables together (MySQL), grouped by a 'tracking number' and an 'order_ID':</p>
  
  <pre><code>invoice_data_dhl
  master_track_nums
  payments
  </code></pre>
  
  <p><strong><em>Problem</em></strong>: When they are multiple <code>payments</code> rows for an order_ID, it is multiplying the <code>DHL_COST</code> total by the number of results in the <code>payments</code> table for the order_ID.</p>
  
  <pre><code>SELECT 
  invoice_data_dhl.Waybill_Number,
  sum(invoice_data_dhl.AWB_Original_Amount) AS DHL_COST,
  master_track_nums.order_ID,
  sum(payments.revenue) AS REVENUE
  FROM invoice_data_dhl
  LEFT JOIN master_track_nums
  ON invoice_data_dhl.Waybill_Number = master_track_nums.track
  LEFT JOIN payments
  ON master_track_nums.order_ID = payments.order_ID
  GROUP BY invoice_data_dhl.Waybill_Number
  </code></pre>
  
  <p>Can this be written so that I can get the results with a single query that outputs the results like the below?</p>
  
  <pre><code>Waybill_Number  DHL_COST    order_ID    REVENUE
  7022193792       182.52       110632      234
  4536137201      3311.96       107637     4074
  3927382187       248.95       110384      636
  7812896712        74.85       106998      247
  </code></pre>
  
  <p>Thanks for any help in advance!</p>