title: Calculate running total / running balance
body: <p>I have a table:</p>
  
  <pre><code>create table Transactions(Tid int,amt int)
  </code></pre>
  
  <p>With 5 rows:</p>
  
  <pre><code>insert into Transactions values(1, 100)
  insert into Transactions values(2, -50)
  insert into Transactions values(3, 100)
  insert into Transactions values(4, -100)
  insert into Transactions values(5, 200)
  </code></pre>
  
  <p>Desired output:</p>
  
  <pre><code>TID  amt  balance
  --- ----- -------
  1    100   100
  2    -50    50
  3    100   150
  4   -100    50
  5    200   250
  </code></pre>
  
  <p>Basically for first record balance will be same as <code>amt</code>, 2nd onwards balance would be addition of previous balance + current <code>amt</code>. I am looking for an optimal approach. I could think about using function or correlated subquery but not sure exactly how to do it. </p>