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, 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

Thanks,

Russell.


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


--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577


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

Reply via email to