En metod använder två nivåer av analytiska funktioner:
select t.*, max(running_avg_3) over (partition by item_id)
from (select t.*,
avg(qty) over (partition by item_id order by year desc
rows between current row and 2 following
) as running_avg_3
from t
) t