title: Subtract fields in the same column to get interval
body: <p>I have a table "@table1" and I would like recursively update on the"Amount" column from the BOTTOM to the TOP ordering by RowID. That is taking the negative values subtracting that value with value of row above, if the end result is still a negative subtract that value with the next row, replacing the previous value with 0. </p>
  
  <pre><code> DECLARE @table1 TABLE (RowID int, Amount int);
      INSERT @table1 VALUES 
      (1,20),
      (2,10),
      (3,-10),
      (4,10),
      (5,-5),
      (6,30);
  Select * from @table1
  
  
  RowID       Amount
  ----------- -----------
  1           20
  2           10
  3           -10
  4           10
  5           -5
  6           30
  </code></pre>
  
  <p>Results Table</p>
  
  <pre><code>DECLARE @table1 TABLE (RowID int, Amount int);
      INSERT @table1 VALUES 
      (1,20),
      (2,0),
      (3,0),
      (4,5),
      (5,0),
      (6,30); 
  Select * from @table1
  
  
  RowID       Amount
  ----------- -----------
  1           20
  2           0
  3           0
  4           5
  5           0
  6           30
  </code></pre>