title: Problem inserting database row using last row in sqlite
body: <p>I'd like to be able to do the following initially and also at anytime.</p>
  <pre class="lang-sql prettyprint-override"><code>insert into balance (closing_amount, opening_amount, created, tx_id)
  
  select closing_amount + :value, closing_amount, :date, :tx_id from balance order by id desc limit 1
  </code></pre>
  <p>Basically I'm inserting by using previous values. But if there are no values to begin with, nothing gets inserted.</p>
  <p>I could use a union to which works the first time but duplicates on subsequent inserts.</p>
  <p>I want to avoid two trips. Is there a way to do this?</p>
  <p>Also, the tx_id will always be unique.</p>