Hello everybody.
I have this table (Table1):
Rank | DueDate | Module | Amount |
1 | 01/01/2012 | C1 | 20 |
2 | 01/06/2012 | C2 | 32 |
3 | 01/01/2013 | C1 | 5 |
4 | 05/03/2013 | C2 | 10 |
5 | 05/03/2013 | C1 | 25 |
6 | 12/03/2013 | C1 | 10 |
7 | 12/04/2013 | C1 | 46 |
8 | 03/05/2013 | C1 | 35 |
9 | 27/05/2013 | C1 | 12 |
10 | 15/06/2013 | C2 | 6 |
I need I accumulative field with this behavior in this select:
SELECT Rank, DueDate, Module, Amount
FROM Table1
WHERE (Module = ‘C1’ AND YEAR(DueDate)=2013)
ORDER BY Rank
With this result:
Rank | DueDate | Module | Amount | Acumulative |
3 | 01/01/2013 | C1 | 5 | 5 |
5 | 05/03/2013 | C1 | 25 | 30 |
6 | 12/03/2013 | C1 | 10 | 40 |
7 | 12/04/2013 | C1 | 46 | 86 |
8 | 03/05/2013 | C1 | 35 | 121 |
9 | 27/05/2013 | C1 | 12 | 133 |
Or this, doesn’t matter, if it’s possible:
Rank | DueDate | Module | Amount | Acumulative |
1 | 01/01/2013 | C1 | 5 | 5 |
2 | 05/03/2013 | C1 | 25 | 30 |
3 | 12/03/2013 | C1 | 10 | 40 |
4 | 12/04/2013 | C1 | 46 | 86 |
5 | 03/05/2013 | C1 | 35 | 121 |
6 | 27/05/2013 | C1 | 12 | 133 |
The result that I need is if I filter by Module or filter by DueDate, the accumulated field is correct.
Can you help me, please?
Thanks a lot!