0

I need to get a set of total transactions over time on a weekly interval. Essentially I need a total-transactions-to-date column.

When I group by WEEK(Date) I get the amount of transactions for that week, but need to also get the transactions from any time before that week as well.

So let's say I have a table like this:

TransactionID  | Date
---------------|-----------
             1 | 8-04-2014
             2 | 8-05-2014
             3 | 8-18-2014
             4 | 8-18-2014
             5 | 8-20-2014

I want to have a select statement that would provide me with something like

TotalTransactionsToDate | Week | Year
------------------------|------|------
                      2 |    1 | 2014
                      5 |    3 | 2014

If I could somehow also get the row 2 | 2 | 2014 meaning 2 Total, on Week 2 of 2014 that would be a nice bonus, but I don't require it.

I am using MySql 5.5.38

0

0

Browse other questions tagged or ask your own question.