title: Oracle SQL - Running Sum based on group by and condition
body: <p>I have table that looks like </p>
  
  <pre><code>ID      SEQ       LABEL     COUNT
  1        1           0       3
  1        2           0       2
  1        3           0       6
  1        4           1       2
  1        5           0       3
  1        6           0       5
  2        1           0       2
  2        2           1       1
  2        3           0       3
  </code></pre>
  
  <p>I would like to create a column called running_count. It calculates cumulative sum of the column count till the Label is 1 and then reset and start cumulative sum again.</p>
  
  <p>Expected Output:</p>
  
  <pre><code>ID      SEQ       LABEL1     COUNT1     RUNNING_COUNT
  1        1           0       3              3
  1        2           0       2              5
  1        3           0       6              14
  1        4           1       2              16
  1        5           0       3              3
  1        6           0       5              8
  2        1           0       2              2
  2        2           1       1              3
  2        3           0       3              3
  </code></pre>
  
  <p>I tried the following query</p>
  
  <pre><code>SELECT A.*, SUM(COUNT1) over (partition by ID,LABEL1 order by SEQ) as RUNNING_COUNT FROM TABLE_1 A
  </code></pre>
  
  <p>The problem here is that the cumulative sum stops in previous row(Seq) for Label = 1. I need to get the running sum till Label = 1 for Each ID based on Seq.</p>
  
  <p>The Wrong Output I am getting </p>
  
  <pre><code>ID      SEQ       LABEL1     COUNT1     RUNNING_COUNT
  1        1           0       3              3
  1        2           0       2              5
  1        3           0       6              14
  1        4           1       2              2
  1        5           0       3              3
  1        6           0       5              8
  2        1           0       2              2
  2        2           1       1              1
  2        3           0       3              3
  </code></pre>