Skip to content
Advertisement

Trying to get Price Difference and Percent Difference

I am trying to find the daily price difference and the daily percent difference, in one field, in one table. Here is the code that I am testing.

Here is a sample of my data (first three fields), with the expected results (last two fields named ‘PriceDiff’ & ‘PercentDiff’).

I am using SQL Server.

Advertisement

Answer

You seem to want lag():

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement