Reputation: 11
The Third Output is All I want I query that using sql server 2012 using this query
Select LACCT,LREFNO,CONVERT(char(10), LDATE, 101) AS DATE,Description,Debit,Credit,Balance
From
(
SELECT
LACCT,
LREFNO,
LDATE,
Description,
Debit,
Credit,
SUM(Debit - Credit) OVER (ORDER BY LDATE ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS Balance
FROM
(
Select
a.LACCT,
a.LREFNO,
a.LDATE,
b.Description ,
case when a.LDBCR = 'D' then cast(a.LAMOUNT AS decimal(20,2)) else '0.0' end Debit,
case when a.LDBCR = 'C' then cast(a.LAMOUNT AS decimal(20,2)) else '0.0' end Credit
FROM [dbo].[BCS02001] AS a
JOIN [dbo].[ref_LedgerParticulars] as b ON a.LCODE = b.Code
where a.LACCT= @AcntNo
) LedgerTable ) tblAll where year(LDATE) = @YEAR
But this Query is not Running on SQL SERVER 2008 r2
OVER (ORDER BY LDATE ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
How can I convert this to sql; server 2008 r2
thank you
Upvotes: 1
Views: 214
Reputation: 7250
Remove this from the code:
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
It is something v2008 doesn't support. However, removing it will not change anything, as this line is the default window.
Upvotes: 2