Preview:
--moving average
With US_medals as ()

select year,medals,
  avg(medals)over(order by year asc rows between 2 preceding and current row) as medasls_MA
from US_medals
order by year asc;

--moving total
With US_medals as ()

select year,medals,
  sum(medals)over(order by year asc rows between 2 preceding and current row) as medasls_MT
from US_medals
order by year asc;
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter