I am trying to have a running average column in the SELECT statement based on a column from the n previous rows in the same SELECT statement. The average I need is based on
Edit: I missed the point that it should average the three previous records...
For a general running average, I think something like this would work:
SELECT id, number, SUM(number) OVER (ORDER BY ID) / ROW_NUMBER() OVER (ORDER BY ID) AS [RunningAverage] FROM myTable ORDER BY ID