Moving Average of last 30 Items sold
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