[Solved] Group by and calculation from value on the next row


You can easily calculate the % difference using lag()

select name, date, number, 
Cast(((number * 1.0) - Lag(number,1) over(partition by name order by date))/ Lag(number,1) over(partition by name order by date) * 100 as int)
from table

solved Group by and calculation from value on the next row