title: Insert row with cell amount dependent of previous row cell amount
body: <p>I have a system balance table "<code>A</code>", where the column "amount" is a debit/credit column, like this:</p>
  
  <pre><code>id amount balance 
  1  100    100 
  2  -30    70 
  3  40     110
  4  -20    90
  </code></pre>
  
  <p>If a new deposit is made of i.e. $50, the new row would have to be inserted as:</p>
  
  <pre><code>5  50      140
  </code></pre>
  
  <p>I could achieve this by selecting last balance:</p>
  
  <pre><code>SELECT id, balance
  FROM A
  ORDER BY id DESC LIMIT 1
  </code></pre>
  
  <p>and then inserting new row:</p>
  
  <pre><code>INSERT INTO A (amount, balance)
  VALUES (50, previous_balance+50)
  </code></pre>
  
  <p>But, is there a way to achieve this with only one query? Would it be efficient on large databases? Thank you!</p>