You can get a prior day value using the Lag Function in SQL Server.
In this video I show you how to create a prior day squeeze of profit using the Windowing Lag function in TSQL.
This video builds on the prior day’s video, Moving Average with Windowing.
I use the Wide World Importers and the following scripts:
select
[Invoice Date Key],
Profit,
Lag(Profit,1) OVER (ORDER BY [Invoice Date Key]) as PriorDayProfit,
Profit - isnull(Lag(Profit,1) OVER (ORDER BY [Invoice Date Key]),0) as DailySqueeze
from dbo.ProfitByDate
order by 1
Link to the Microsoft SQL Server Over Clause.
See the original SQL Prior Day Profit - Lag Windowing Function video.