I want to rename a column after calculating the difference between current row and previous row by using over clause (windows function)
However, I cannot run it and it shows that I have a error in my sql syntax
select country,year,
avg(oil_consumption) OVER (partition by country
order BY year
ROWS BETWEEN 2 PRECEDING AND current row )
as 3_year_moving_average, (3_year_moving_average-lag(3_year_moving_average,1) over (partition by country) **as** difference_between_previous_current
from owid_energy_data
Error at the second as (bolded)