I am using embedded derby database and I want to add running balance column by calculating debit and credit amounts so please tell me solution code and image are also available below
(as you can see in image balance total is not accurate)
SELECT
V_DATE,FLAG,V_NUM,V_NARATION,
sum(VDTL.DR_AMOUNT) AS DEBIT,
sum(VDTL.CR_AMOUNT) AS CRIDIT,
sum(dr_amount)-sum(cr_amount) as total
FROM VOUCHARDETAIL AS VDTL
INNER JOIN VOUCHARMASTER AS VMST
ON VDTL.DTL_NUM =VMST.MST_NUM
WHERE (V_DATE BETWEEN '12-03-2017' AND '14-03-2017') AND (FLAG='IV' OR FLAG='BR'
OR FLAG='CP' OR FLAG='CR' OR FLAG='JV' OR FLAG='BP') AND (AC_CODE=60030002)
GROUP BY
V_DATE,FLAG,V_NUM,V_NARATION
ORDER BY
V_DATE