List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:April 5 2008 4:32pm
Subject:Re: Incorrect results from sum
View as plain text  
Jonathan,

Jake provided useful suggestions & answered your question. For 
elaboration of Jake's tip, see the manual page for GROUP BY for how 
joins affect grouping.

PB

-----

Jonathan Mangin wrote:
>
> ----- 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.
>
>
>
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