List:MySQL++« Previous MessageNext Message »
From:Kerry Frater Date:November 21 2006 3:24pm
Subject:RE: Running Totals with MySQL
View as plain text  
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
where myref='Ref1'
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
variables?

My attempts so far have failed miserably

Kerry



-----Original Message-----
From: Kerry Frater [mailto:kerry@stripped]
Sent: 21 November 2006 07:31
To: plusplus@stripped
Subject: Running Totals with MySQL


I need to keep a running total (not an aggregate) based on data in two
columns e.g.
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.

Kerry


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe:
http://lists.mysql.com/plusplus?unsub=1

Thread
Exception of type std::length_errorMathieu Pagé13 Nov
  • Re: Exception of type std::length_errorWarren Young14 Nov
    • Re: Exception of type std::length_errorMathieu Pagé14 Nov
Re: Exception of type std::length_errorMathieu Pagé19 Nov
  • Re: Exception of type std::length_errorWarren Young20 Nov
    • Running Totals with MySQLKerry Frater21 Nov
      • RE: Running Totals with MySQLKerry Frater21 Nov
      • Re: Running Totals with MySQLWarren Young22 Nov
        • RE: Running Totals with MySQLKerry Frater28 Nov