Hi Henrique,
The SQL,
SELECT id, date, col1, sum(col1) over (partition by col1 orderby id, date) as cumulative_sum
will give me the cumulative value for all the col 1 with same value which is not my requirement,
the above will give the result as shown below. I have also added the correct values as per my requirement as well
ID Date column 1 Cumulative sum correct ***_sum
1 9-14-2014 14:05:00 1 1 1
1 9-14-2014 14:22:00 1 2 2
1 9-14-2014 14:25:00 1 2 3
1 9-14-2014 14:37:00 0 0 0
1 9-14-2014 15:02:00 0 0 0
1 9-14-2014 15:12:00 1 4 1
1 9-14-2014 15:18:00 1 5 2
1 9-14-2014 15:21:00 1 6 3
2 9-14-2014 13:22:00 0 0 0
2 9-14-2014 14:25:00 1 1 1
2 9-14-2014 14:32:00 1 2 2
for my requirement , I need to find the cumulative value only for the consecutive 1s if there are 0s in between then there should be a break and cumulative sum should start again for the next set of consecutive 1s
Hope you could help. Thanks.
-Gayathri