List:General Discussion« Previous MessageNext Message »
From:Jonathan Mangin Date:April 5 2008 3:42pm
Subject:Incorrect results from sum
View as plain text  
I'm getting incorrect results from a sum and wonder if
anyone sees something obviously wrong. (Won't surprise
me.) Leaving 'simple' out of the equation (or adding
'simple' values manually) gets me the correct number.

$menu is a personalized table of meal/recipe ingredients.
itemized is a list of ingredients consumed in each meal.
simple is a table of nutrient totals for each meal.

(I want the user to be able to choose simple or
itemized storage at any time.)

$menu.carb is decimal(8,3)
simple.carb is decimal(4,1)

select round(sum($menu.carb * units) + simple.carb,2)
from itemized inner join simple on itemized.uid = simple.uid
inner join $menu on itemized.personal_id = $menu.id
where itemized.uid = ? and itemized.date between ? and ?
group by date;

It's supposed to return 253.08, but I keep getting 260.36.


Thanks alot,
Jon




Thread
Incorrect results from sumJonathan Mangin5 Apr
  • Re: Incorrect results from sumJake Peavy5 Apr
  • Re: Incorrect results from sumJonathan Mangin5 Apr
    • Re: Incorrect results from sumPeter Brawley5 Apr
  • Re: Incorrect results from sumJonathan Mangin6 Apr
    • Re: Incorrect results from sumPerrin Harkins6 Apr
      • Re: Incorrect results from sumBaron Schwartz7 Apr