----- Original Message -----
From: "Jake Peavy" <djstunks@stripped>
To: "Jonathan Mangin" <jon.mangin@stripped>
Cc: <mysql@stripped>
Sent: Saturday, April 05, 2008 11:59 AM
Subject: Re: Incorrect results from sum
> On 4/5/08, Jonathan Mangin <jon.mangin@stripped> wrote:
>>
>> 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.
>>
>>
>> select round(sum($menu.carb * units) + simple.carb,2)
I was hoping for a syntax error on the above line. This has
worked fine until I added simple.
>> 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.
>>
>
>
> Your "bug" is likely in the GROUP BY.
>
> --
> -jp
>
There is only one day's meals stored and a difference of 7.28
relates to no stored values. Thanks anyway.