Moving Average n Moving Total
Wed Mar 23 2022 06:56:58 GMT+0000 (Coordinated Universal Time)
Saved by
@Bambibo9799
--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;
content_copyCOPY
Comments