Here is my query with left join and I am automatically developing credit debit and balance.

Perhaps I am lacking upon column. I used `gl_drcr` as main column and split it by query into credit and debit but I am unable to get value of balance. I have column of amount also, where I can store amount values.

Can you help me to sort out where my fault is in this query?

My stored procedure looks like this:

```
ALTER procedure [dbo].[sp_getDataML]
    (@gl_acid int, @userid int)
AS
BEGIN
    SELECT 
        ROW_NUMBER() OVER (ORDER BY gLedeger.PK_id) AS sno,
        CASE 
           WHEN master.ma_accname IS NULL THEN '' 
           ELSE ma_accname 
        END AS AccName, 
        gLedeger.gl_date AS date, gLedeger.gl_narration AS Narration, 
        gLedeger.gl_drcr as DRCR,
        CASE
           WHEN gLedeger.gl_drcr > 0 THEN ABS(gLedeger.gl_drcr) 
           ELSE 0.00 
        END AS debit,
        CASE 
           WHEN gLedeger.gl_drcr < 0 THEN ABS(gLedeger.gl_drcr) 
           ELSE 0.00 
        END AS credit,
        SUM(COALESCE(gLedeger.gl_drcr.credit, 0) - COALESCE(gLedeger.gl_drcr.debit, 0)) AS Balance  
    FROM 
        gLedeger   
    LEFT JOIN 
        master ON gLedeger.GL_ACID = master.PK_ID 
    LEFT JOIN
        registration r ON master.userId = @userid
    WHERE 
        gLedeger.GL_ACID = @gl_acid
        /*and LEFT(gLedeger.gl_voucher,2)=@voucher*/
    ORDER BY 
        gLedeger.gl_date
END

```