title: SQL - cumulative sum in postgres
body: <p>I have my data like this:</p>
  
  <pre><code>item - initial_value - amount - dateofpurchase 
  A       100             -3      2018-11-22          
  A       100             -2      2018-11-22      
  B       200             -5      2018-11-22
  B       200             6       2018-11-22
  B       200             -1      2018-11-22
  </code></pre>
  
  <p>(everything is ordered by date and time)</p>
  
  <p>I want to calculate this column, that shows how much stock do you have after each step and taking in count the last amount</p>
  
  <pre><code>item - initial_value - amount - dateofpurchase - cumulative
  A       100             -3      2018-11-22          97
  A       100             -2      2018-11-22          95
  B       200             -5      2018-11-22          195
  B       200             6       2018-11-22          201
  B       200             -1      2018-11-22          200
  </code></pre>
  
  <p>I've been trying a sum function with unbounded preceding and current row with no luck</p>