What is the best way to find out the sum of a field from a table? I am making a accounting software. I have a table debit_credit that contains double entry accounting records
Here is my example
data.Table is:
debit_credit_id | tran_id | ledger_head_id | debit | credit | dr_cr | commission | commission_type
--------------------------------------------------------------------------------------------------
1               | 2       |  5             | 500   | 0      | Dr    | null           | null

1               | 2       |  5             | 0     | 500    | Cr    | null           | null

This tables contains many rows and I have to run the following query several times:
'SELECT SUM(debit) - SUM(credit) FROM debit_credit WHERE ledger_head_id=$id'

But my project manager proposed, to make a  default view to making the sum. After that, when I need the sum just query from that view as
'SELECT debit - credit FROM debit_credit_view WHERE ledger_head_id=$id';

But I would prefer to use first method with stored procedure instead of the method proposed by my project manager.
Sql fiddle: http://sqlfiddle.com/#!9/cc594/1
What is the best way?
VIEWs do not improve performance.  (You are talking about CREATE VIEW, correct?)

Either of these is perfectly good:

SELECT SUM(debit) - SUM(credit) FROM debit_credit WHERE ledger_head_id = $id
SELECT SUM(debit - credit)      FROM debit_credit WHERE ledger_head_id = $id