title: SQLite: Running balance with an ending balance
body: <p>I have an ending balance of $5000. I need to create a running balance, but adjust the first row to show the ending balance then sum the rest, so it will look like a bank statement. Here is what I have for the running balance but how can I adjust row 1 to not show a sum of the first row, but the ending balance instead. </p>
  
  <pre><code>with BalBefore as (
    select *
    from transactions
    where ACCT_NAME = 'Real Solutions'
    ORDER BY DATE DESC
  )
  
  select
    DATE,
    amount,
    '$' || printf("%.2f", sum(AMOUNT) over (order by ROW_ID)) as Balance
  from BalBefore;
  </code></pre>
  
  <p>This gives me"</p>
  
  <pre><code>DATE         AMOUNT     BALANCE
  9/6/2019     -31.00     $-31.00      &lt;- I need this balance to be replaced with $5000 and have the rest
  9/4/2019      15.00     $-16.00         sum as normal.
  9/4/2019      15.00     $-1.00
  9/3/2019     -16.00     $-17.00
  </code></pre>
  
  <p>I have read many other questions, but I couldn't find one that I could understand so I thought I would post a simpler question.</p>