title: Oracle sql math calculation using current and previous row values
body: <p>I have the following table:</p>
  
  <pre><code>ID  A   B   C
  1   1   23  22
  2   2   19  20
  3   5   18  15
  4   3   12  12
  </code></pre>
  
  <p>Columns A and B are constants. I want to calculate column C using the following formula:</p>
  
  <p>for the first row </p>
  
  <pre><code> C = B - A
  </code></pre>
  
  <p>after that</p>
  
  <pre><code> C = previous(C) - A
  </code></pre>
  
  <p>I want to achieve this using only <code>oracle</code> <code>SQL</code>.</p>