How to calculate balance from debit and credit columns for mysql



  • I Have two columns Debit and Credit and want query to calculate balance from debit and credit for individual customer as shown below in the image: enter image description here



  • Got my solution: select ledger_date ,ledger_desc ,ledger_debit, ledger_credit, sum(ledger_debit) over (order by ledger_id) - sum(ledger_credit) over (order by ledger_id) as Balance from tblledger




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2