Calculate percent change between 2 rows in SQL Server using CTE
A common table expression (CTE) is used in this example to create a temporary result set with a sequential number that allows us to do the arithmetic required to calculate percent change.