I have come across and modified a nice little solution to this with a big
BUT. The code works out to be
select @runbal:=@runbal+modamount1+(modamount2 * -1) as runbal, t.*
from (select @runbal:=0) rt,mytable t
order by date,uniqueref
This gives me the running total results I want except that I use Delphi with
MicroOlap's DAC to interface with MySQL and their TMySQLQuery doesn't
support this construct.
MicroOlap tell me that it will work in the next release.
Can someone give me another way to do the same thing without the use of
My attempts so far have failed miserably
From: Kerry Frater [mailto:kerry@stripped]
Sent: 21 November 2006 07:31
Subject: Running Totals with MySQL
I need to keep a running total (not an aggregate) based on data in two
a b calculated_col
100 -10 90
50 10 150
-10 -20 120
the rows are selected on certain WHERE criteria and so the running total is
not fixed data. The running total is for display on the screen.
Doing this work in the language interfacing with MySQL is causing some odd
side effects so I was hoping to do the work on the MySQL side instead.
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus