Re: Incorrect results from sum

2008-04-15 Thread Sebastian Mendel
Jonathan Mangin schrieb: I'm trying to total certain nutrients consumed on a given date (though I've removed date temporarily). You'll see I have three items (in two meals) in itemized, and two meal totals in simple. mysql select id, item, carb from my_menu where id in (10, 11, 22);

Re: Incorrect results from sum

2008-04-15 Thread Perrin Harkins
On Tue, Apr 15, 2008 at 4:21 AM, Sebastian Mendel [EMAIL PROTECTED] wrote: use UNION You can't use UNION to add the results of two queries. It would return two rows. - Perrin -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:

Re: Incorrect results from sum

2008-04-15 Thread Sebastian Mendel
Perrin Harkins schrieb: On Tue, Apr 15, 2008 at 4:21 AM, Sebastian Mendel [EMAIL PROTECTED] wrote: use UNION You can't use UNION to add the results of two queries. It would return two rows. of course! you need to use this UNION as subquery sorry for being not imprecise -- Sebastian --

Incorrect results from sum

2008-04-14 Thread Jonathan Mangin
Sorry to return to this topic, I haven't found a lot to explain what's happening. I'm trying to total certain nutrients consumed on a given date (though I've removed date temporarily). You'll see I have three items (in two meals) in itemized, and two meal totals in simple. mysql select id,

Re: Incorrect results from sum

2008-04-14 Thread Perrin Harkins
On Mon, Apr 14, 2008 at 5:40 PM, Jonathan Mangin [EMAIL PROTECTED] wrote: select round(sum(my_menu.carb * units) + sum(simple.carb),2) from itemized inner join simple using (uid) left join my_menu on itemized.personal_id = my_menu.id; Instead of 218.3 this returns 602, which is (52.9

Re: Incorrect results from sum

2008-04-06 Thread Baron Schwartz
Hi, On Sun, Apr 6, 2008 at 12:54 AM, Perrin Harkins [EMAIL PROTECTED] wrote: On Sat, Apr 5, 2008 at 9:28 PM, Jonathan Mangin [EMAIL PROTECTED] wrote: select itemized.day_date as day_date, round(sum(my_menu.carb * units) + simple.carb,2) from itemized inner join simple using (uid)

Incorrect results from sum

2008-04-05 Thread Jonathan Mangin
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

Re: Incorrect results from sum

2008-04-05 Thread Jake Peavy
On 4/5/08, Jonathan Mangin [EMAIL PROTECTED] 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. $menu is a

Re: Incorrect results from sum

2008-04-05 Thread Jonathan Mangin
- Original Message - From: Jake Peavy [EMAIL PROTECTED] To: Jonathan Mangin [EMAIL PROTECTED] Cc: mysql@lists.mysql.com Sent: Saturday, April 05, 2008 11:59 AM Subject: Re: Incorrect results from sum On 4/5/08, Jonathan Mangin [EMAIL PROTECTED] wrote: I'm getting incorrect results

Re: Incorrect results from sum

2008-04-05 Thread Peter Brawley
PROTECTED] Cc: mysql@lists.mysql.com Sent: Saturday, April 05, 2008 11:59 AM Subject: Re: Incorrect results from sum On 4/5/08, Jonathan Mangin [EMAIL PROTECTED] wrote: I'm getting incorrect results from a sum and wonder if anyone sees something obviously wrong. (Won't surprise me.) Leaving

Re: Incorrect results from sum

2008-04-05 Thread Jonathan Mangin
Hi, Here's the basic query I'm trying. It's supposed to return the totals of each nutrient (carb, in this case) by date. The data totals 218.31, but I get 190.80. select itemized.day_date as day_date, round(sum(my_menu.carb * units) + simple.carb,2) from itemized inner join simple using (uid)

Re: Incorrect results from sum

2008-04-05 Thread Perrin Harkins
On Sat, Apr 5, 2008 at 9:28 PM, Jonathan Mangin [EMAIL PROTECTED] wrote: select itemized.day_date as day_date, round(sum(my_menu.carb * units) + simple.carb,2) from itemized inner join simple using (uid) inner join my_menu on itemized.personal_id = my_menu.id where itemized.uid = 'me' and