I am trying to get the running total for Week (like Show as 'Running Total in' in Excel Pivot table.
I have tried with the below query.
select A.*,
(SELECT SUM(b.value)
FROM Tbl_Running_Total_Test B
WHERE B.Fweek <= A.Fweek
AND A.level1=B.level1
AND A.level2=B.level2
AND A.level3=B.level3
AND A.level4=B.level4
)
from Tbl_Running_Total_Test A
Here is a SQL Fiddle: SQl Fiddle Sample table
If I use the above query I am not getting the expected result. 