How to Calculate ruining Balance in Sql Server 2008. i am using following query working perfectly in sql server 2012 but not in sql server 2008.
SELECT empid, tentryno, glcode, descript, linenarrat, ttype, amount, tapplid, ftype, mentryno, mthttype, entrydate, ref, refdate, remarks, narrat, postflag, mapplid, mtype, post, acctheadcode, accthead, subacctheadcode, subaccthead
, CASE
WHEN ttype = 'D'
THEN amount
ELSE 0.00
END AS Debit, CASE
WHEN ttype = 'C'
THEN amount
ELSE 0.00
END AS Credit, SUM(CASE
WHEN ttype = 'D'
THEN amount
ELSE amount * - 1
END) OVER (
PARTITION BY glcode ORDER BY tseqid
) AS balance, STATUS, receid, system.title, dbo.system.address, dbo.system.phone1, dbo.system.phone2, dbo.system.fax, dbo.system.signimage, dbo.system.logo
FROM CreditDebitDetails
CROSS JOIN system
WHERE STATUS != 0