List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:April 18 2006 3:18pm
Subject:Re: My Left Joins are Doubling the SUM()
View as plain text  
mysql,

Add a grouping clause to that query, ie

SELECT
  packageItemID,
  SUM(packageItemPrice),
  ( SELECT SUM(c.packageCreditAmount)
    FROM packageCredit c
    WHERE c.packageCreditItemID = packageItemID
  ) AS CreditSum,
  ( SELECT SUM(t.packageItemTaxAmount)
    FROM packageItemTax t
    WHERE t.packageItemTaxItemID = packageItemID
  ) AS TaxSum
FROM packageItem
GROUP BY packageItemID;

PB



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.4.3/317 - Release Date: 4/18/2006

Thread
My Left Joins are Doubling the SUM()mysql18 Apr
  • Re: My Left Joins are Doubling the SUM()Martijn Tonies18 Apr
  • Re: My Left Joins are Doubling the SUM()Peter Brawley18 Apr
  • Re: My Left Joins are Doubling the SUM()Peter Brawley18 Apr