SELECT
nm_bu,
id_cal_mth ,
AVG(qty) OVER (PARTITION BY nm_bu ORDER BY id_cal_mth ROWS 2 PRECEDING)
FROM
(
SELECT
nm_bu,
id_cal_mth,
SUM(qty_itm) AS qty
FROM
vugd_sal_act_mth
GROUP BY
nm_bu,id_cal_mth
WHERE
nm_bu = 'TV'
) AS TBL
ORDER BY
id_cal_mth
No comments:
Post a Comment