tdietrich
06/17/2021, 10:15 AMSELECT
Transaction.Type,
Transaction.TranID,
Transaction.TranDate,
BUILTIN.DF( Transactionline.Item ) AS ItemName,
TransactionLine.NetAmount,
AVG( TransactionLine.NetAmount )
OVER (
ORDER BY
Transaction.TranID
RANGE BETWEEN 3 PRECEDING AND CURRENT ROW
) AS RollingNetAmtAvg1,
AVG( TransactionLine.NetAmount )
OVER (
ORDER BY
Transaction.TranID
ROWS UNBOUNDED PRECEDING
) AS RollingNetAmtAvg2
FROM
Transaction
INNER JOIN TransactionLine ON
( TransactionLine.Transaction = Transaction.ID )
WHERE
( Transaction.Type = 'PurchOrd' )
AND ( Transactionline.Item = 119 )
ORDER BY
Transaction.TranID
What surprises me the most is that it doesn't throw a parse error. Instead, it just seems to ignore the range.
That being said, if you try using "ROWS 3 FOLLOWING" as the range, it will throw an error.