Advanced SQL Climate Change

Hello!
I’ve done the Advanced SQL Climate Change (Windows Functions).
Any feed back will be more than welcomed.

Here is a link with my solution.

Best rregards!

1 Like

I didn’t check them all - but #5 I was working on. I found one small error. The code runs, but I noticed that the change_in_temp showed to be equal to the temp (I’m using tempf instead of tempc, but it shouldn’t matter). I was able to get this to work:

select
  state,
  year,
  tempf,
  tempf - lag(tempf,1,tempf) over (
    partition by state
    order by year 
  ) as 'change_in_temp'
from state_climate
order by change_in_temp desc;