Một phương pháp sử dụng hai mức hàm phân tích:
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