So, like this? Note the index statement.
select
RANK() over (order by saledate) as rankOrder
, saledate
, saleprice
into #temp
from sales;
select * from #temp;
create index i_saledate on #temp(saledate);
;WITH CTE (rankOrder, SaleDate, [SalePrice], [Running Total])
AS
(
SELECTrankOrder,
SaleDate,
[SalePrice],
[SalePrice]
FROM #temp
WHERE rankOrder = 1
UNION ALL
SELECTa.rankOrder,
a.SaleDate,
a.[SalePrice],
CTE.[Running Total] + a.[SalePrice]
FROM CTE
JOIN #temp a ON CTE.rankOrder + 1 = a.rankOrder
)
SELECT * FROM CTE
OPTION (MAXRECURSION 0)
GO