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 above a certain value in constant time as
well.
I'm in the process of implementing B-trees in procedural SQL so that I
can do this efficiently, but I wanted to make sure I wasn't
duplicating anyone's effort.
Frederik
On Fri, May 27, 2005 at 03:07:24PM -0400, [EMAIL PROTECTED] wrote:
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, 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 totals per month using a query like:
SELECT SUM(amount) , DATE_FORMAT( `paymentDate` , '%Y-%m' ) FROM
`payments` GROUP BY DATE_FORMAT( payments . date , '%Y-%m' )
That would give me:
amount | paymentDate
200| 2005-01
58 | 2005-02
Is there any way to get a running cumulative total directly from mysql?
Something like:
amount | paymentDate
200| 2005-01
258| 2005-02
http://dev.mysql.com/doc/mysql/en/variables.html
:D
Thanks,
Russell.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
_
Douglas Denault
http://www.safeport.com
[EMAIL PROTECTED]
Voice: 301-469-8766
Fax: 301-469-0601
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
--
http://ofb.net/~frederik/
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]