SQL using while loop until nex row doesn't match condition
<p>I have a view looking like this below. <br>
The <code>Value</code> describes a condition in the view. All rows are ordered by their date. My plan is to sum up all amounts where the value is 0 until there is a row with the value 1. <br>
In this case the result should be 20+15=35. Row <code>#4</code> need to be ignored because the value 1 in row 3. </p>

<pre><code>Row | Value | Amount | Date       |
-----------------------------------  
1   | 0     | 20     | 01.01.2016 |
2   | 0     | 15     | 02.01.2016 |    
3   | 1     | 50     | 03.01.2016 |
4   | 0     | 50     | 04.01.2016 |
5   | 1     | 10     | 05.01.2016 |
</code></pre>

<p>Has somebody an idea to solve this in SQL?</p>