title: Calculating opening balance of a month using Mysql
body: <p>Could someone explain the simplest method of calculating opening balance of a month using Mysql. For calculating opening balance I have month as input and debit amount and credit as table fields. I want to calculate opening balance up to a particular month.</p>
  
  <pre><code>TransactionId DebitAmount CreditAmount TransactionDate 
  ------------- ----------  ------------ ---------------- 
  1             40000       500000    2015-12-07 
  2             60000       700000    2015-12-08 
  3             90000       800000    2015-12-11 
  4              5000         3000    2015-12-11 
  5             70000        90000    2015-12-11 
  
  Input: Month : Jan 
  
  Expected Output 
  OpeningBalance 
  -------------- 
  Debit : SomeAmount 
  Credit : SomeAmount 
  </code></pre>