I am trying to create a SQL statement to calculate a 6 month rolling average for my data. I am following this guide:
SQL Query for 7 Day Rolling Average in SQL Server
but the problem is I am using SQL Server 2008 and the answer here is for 2012.
select
x.*,
avg(dailyusage) over(partition by productid order by productid, date rows between 6 preceding and current row) as rolling_avg
from
(select
productid, date, sum(usagecount) as dailyusage
from tbl
group by productid, date) x
It will be appreciated if someone can help me translate it over to 2008 terms.
Thanks