Re: running sum with a @variable

2007-02-06 Thread Brent Baisley
Sent: Tuesday, February 06, 2007 9:45 AM Subject: Re: running sum with a @variable Thanks Lars, Dusan, I found out that the problem is caused by an ORDER BY clause, left out in my example because I had no idea this would be the problem. It works fine with LEFT JOIN and GROUP BY. However,

Re: running sum with a @variable

2007-02-06 Thread C.R.Vegelin
- Original Message - From: "Lars Schwarz" <[EMAIL PROTECTED]> To: Sent: Tuesday, February 06, 2007 12:58 PM Subject: Re: running sum with a @variable oops, sorry, forget the last post i made. it's not related to the group by. it should work like that from my point of view. a

Re: running sum with a @variable

2007-02-06 Thread Lars Schwarz
oops, sorry, forget the last post i made. it's not related to the group by. it should work like that from my point of view. a stripped down version of this works for me (tried without the left join) On 2/6/07, Lars Schwarz <[EMAIL PROTECTED]> wrote: i suppose this to be working when you leave th

Re: running sum with a @variable

2007-02-06 Thread DuĊĦan Pavlica
try to put parenthesis around @runsum := @runsum + SUM(db.Jan+db.Feb+db.Mar) SELECT @row := @row+1 AS `Row`, mycountries.Name AS `Country` , ROUND(SUM(db.Jan+db.Feb+db.Mar)) AS `Q1` , (@runsum := @runsum + SUM(db.Jan+db.Feb+db.Mar)) AS `RunSum` FROM data2006 AS db LEFT JOIN mycountries ON db.Cou

Re: running sum with a @variable

2007-02-06 Thread Lars Schwarz
i suppose this to be working when you leave the group by? On 2/6/07, C.R.Vegelin <[EMAIL PROTECTED]> wrote: I want to calc a running sum with @variables. Using the command line client, I enter: SET @row := 0, @runsum := 0; followed by: SELECT @row := @row+1 AS `Row`, mycountries.Name AS `Country

running sum with a @variable

2007-02-06 Thread C.R.Vegelin
I want to calc a running sum with @variables. Using the command line client, I enter: SET @row := 0, @runsum := 0; followed by: SELECT @row := @row+1 AS `Row`, mycountries.Name AS `Country` , ROUND(SUM(db.Jan+db.Feb+db.Mar)) AS `Q1` , @runsum := @runsum + SUM(db.Jan+db.Feb+db.Mar) AS `RunSum` FRO