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`
, 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.Country = mycountries.ID
 WHERE ...
 GROUP BY db.Country;


Results are:
Row  Country     Q1    RunSum
  1     Germany   90    90
  2     France      60    60
  3     Norway     24    24
etc.

I expect the RunSum for Germany 60, France 150, Norway 174 etc.
Whay am I doing wrong ? Any help is appreciated !

Regards, Cor




--
Lars Schwarz
Gottorpstrasse 20
26122 Oldenburg
T 0441 2171 354 0
F 0441 2171 354 0
M 0179 512 4628

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to