"cumulative total index"
...
> > >SELECT SUM(amount) , DATE_FORMAT( `paymentDate` , '%Y-%m' ) FROM
> > >`payments` GROUP BY DATE_FORMAT( payments . date , '%Y-%m' )
.
> > >Is there any way to get a running cumulative total directly from mysql?
> > >Something like:
> > >
> > >amount | pay
>From this discussion, I'm assuming that there is no support for a
"cumulative total index", is this correct? In other words, I'm looking
for an index which lets me query a cumulative sum of a column in
constant time, and which lets me find a row which has for instance the
smallest cumulative sum a
Just in case you did not follow this suggestion, if you are using 4.0.x this is
very simple. I was looking for this:
set @total:=0;
select f1,f2,...,@total:[EMAIL PROTECTED] as Total from table where ...;
is pretty simple.
On Wed, 25 May 2005, Dan Bolser wrote:
> On Wed, 25 May 2005, Russel
Hi again,
if your looking for raising sub-totals, i found you thos form :
mysql> select 'TOTAL',
-> sum(if(DATE_FORMAT( `paymentDate` , '%Y-%m' )<='2005-01',amount,0)) as
'2005-01',
-> sum(if(DATE_FORMAT( `paymentDate` , '%Y-%m' )<='2005-02',amount,0)) as
'2005-02'
-> from payments
Hi,
aren't you looking for somthing like that :
mysql> select sum(amount),DATE_FORMAT( `paymentDate` , '%Y-%m' ) c FROM
`payments` GROUP BY c with rollup;
+-+-+
| sum(amount) | c |
+-+-+
| 200 | 2005-01 |
| 58 | 2005-02 |
| 2
- Original Message -
From: "Russell Horn" <[EMAIL PROTECTED]>
To:
Sent: Wednesday, May 25, 2005 8:02 AM
Subject: Cumulative Totals
> I have a pretty simple table with a list of payments, not much more
> than:
>
> paymentID | amount | paymentDate
> 1 | 123| 2005-01-10
> 2 | 77
You may be able to use the WITH ROLLUP option of GROUP BY to get
something of what you are looking for. Can't think of anything off the
top of my head to get exactly what you are looking for.
On May 25, 2005, at 8:02 AM, Russell Horn wrote:
I have a pretty simple table with a list of payments
On Wed, 25 May 2005, Russell Horn wrote:
>I have a pretty simple table with a list of payments, not much more
>than:
>
>paymentID | amount | paymentDate
>1| 123| 2005-01-10
>2| 77 | 2005-01-13
>3| 45 | 2005-02-16
>4| 13 | 2005-02-17
>
>
>I can get to