I am creating a running total for specific group in a sequence. In between a sequence zero value occurs for which I have to start the running total from the zero record
select
Sno,
Group,
Value,
sum(Value) over(partition by Group order by Sno) Cum_Value
from
Table
Output:
Sno Group Value CumValue
-------------------------------
1 A 5 5
2 A 10 15
3 A 25 40
4 A 0 40
5 A 10 50
6 A 5 55
7 A 0 55
7 A 20 75
Sno Group Value CumValue
------------------------------
1 A 5 5
2 A 10 15
3 A 25 40
4 A 0 0--> zero occurs [starts running total again]
5 A 10 10
6 A 5 15
7 A 0 0--> zero occurs [starts running total again]
7 A 20 20