Here fooobar.com/questions/30362 / ... is suggested to use a recursive CTE.
;WITH MyCTE AS ( SELECT R.NetWinCURRENCYValue AS NetWin ,dD.[Date] AS TheDay ,ROW_NUMBER() OVER (ORDER BY dD.[Date]) AS RN FROM dimPlayer AS P JOIN dbo.factRevenue AS R ON P.playerKey = R.playerKey JOIN dbo.vw_Date AS dD ON Dd.dateKey = R.dateKey WHERE P.CustomerID = 12345 ) , MyCTERec AS ( SELECT C.TheDay AS [Date] ,ISNULL(C.NetWin, 0) AS NetWin ,ISNULL(C.NetWin, 0) AS CumulativeNetWin ,C.RN FROM MyCTE AS C WHERE C.RN = 1 UNION ALL SELECT C.TheDay AS [Date] ,ISNULL(C.NetWin, 0) AS NetWin ,P.CumulativeNetWin + ISNULL(C.NetWin, 0) AS CumulativeNetWin ,C.RN FROM MyCTERec P INNER JOIN MyCTE AS C ON C.RN = P.RN + 1 ) SELECT * FROM MyCTERec ORDER BY RN OPTION (MAXRECURSION 0)
Please note that this query will work if you have 1 entry == 1 day! If you have multiple entries in one day, the results will be different from others.
source share