How to find sum of rows based of condition
<p>I have following table:</p>

<pre><code>ID Minutes Flag
-- ------- ---- 
A    8      0
A    9      0
A    21     0
A    5      0
B    32     0
B    21     0
</code></pre>

<p>and I have to create a table as below  </p>

<pre><code>ID Minutes Flag
-- ------- ---- 
A    8      0
A    9      0
A    21     1
A    5      0
B    32     1
B    21     0
</code></pre>

<p>basically I have iterate over given table and update flag when sum of minutes reaches 30 or more and then reset sum(have to find a way to store sum) to 0 and start over again till sum reaches 30 or more </p>

<p>Sum should also reset if ID changes (i.e A to B)</p>

<p>Condition: I have to use SQLite</p>