Ajit N

Ajit N

  • 1.3k
  • 352
  • 68.4k

how to get opening and closing balance using MS Access Sql ?

Apr 13 2019 11:25 AM
Hello, I want to show the opening and closing balance which i mentioned in below image and i just want this type of output through ms access sql query.
 
 
i tried this below query but i didn't got the proper output as per my requirement.
  1. select Edate,OB, Cr, Dr, (OB + Cr - Dr) as Bal, srno  
  2. from statement where srno = (select min(srno) from statement)  
  3. union all  
  4. select curr.edate, (curr.OB + prev.Bal), curr.Cr, curr.Dr,   
  5.   (curr.OB + prev.Bal + curr.Cr - curr.Dr) as Bal, curr.srno  
  6. from statement curr inner join statement prev on curr.srno = prev.srno + 1  
 
 so help me how to do this using sql query ?

Answers (2)