Q:

Subtract current price from previous price in same table with different date with SQL query

I want to subtract Maxprice of 8/10/2018 from Maxprice of 5/10/2018 and  Maxprice of 5/10/2018 from Maxprice of 4/10/2018 and so on for that configurationID. 
After getting that I want to update that change value to the another table.  I need an optimized query for that. 
I have 500 configurations in my table and each configuration has 1000 rows of data. 

A:

You can use SQL Lag() function to read a previous column value in an order set of data
Please try following SQL Select statement
select
*, lag(MaxPrice,1) over (partition by ConfigurationId order by CreatedOn) previousPrice
from PriceHistory

