I would like to count an increase values for each record from this below table (table_values):
id | open | closed | in_progress | project |
1 | 0 | 0 | 0 | 20 |
2 | 1 | 0 | 1 | 20 |
3 | 1 | 1 | 1 | 55 |
4 | 1 | 1 | 1 | 20 |
5 | 1 | 1 | 1 | 20 |
6 | 2 | 2 | 0 | 20 |
So for example to select where project = 20 results should be:
id | open | closed | in_progress | project | Total |
1 | 0 | 0 | 0 | 20 | 0 |
2 | 1 | 0 | 1 | 20 | 2 |
4 | 2 | 1 | 2 | 20 | 3 |
5 | 3 | 2 | 3 | 20 | 3 |
6 | 5 | 4 | 3 | 20 | 4 |
Select should return cumulative results for each id if possible. Any suggestions?
Regards.
UPDATE: TABLE:
id | open |
1 | 2 |
2 | 3 |
3 | 5 |
Result:
id | open | cumulative_open
1 | 2 | 2
2 | 3 | 5
3 | 5 | 10