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
Check out some solutions here. I'm sure that you could adapt one of them easily enough.