移動平均最後 30 個專案
移動平均最近售出的 30 件商品
SELECT
value_column1,
( SELECT
AVG(value_column1) AS moving_average
FROM Table1 T2
WHERE ( SELECT
COUNT(*)
FROM Table1 T3
WHERE date_column1 BETWEEN T2.date_column1 AND T1.date_column1
) BETWEEN 1 AND 30
) as MovingAvg
FROM Table1 T1