我需要你的帮助。
数据库:SQL SERVER 2008R2
我想计算一年零一周的最后一周的平均值。
我有这样的表格数据:
YEAR WEEKS VALUE
2012 1 3000
2012 2 5000
2012 3 6000
2012 4 7000
2012 5 8000
2012 6 9000
2012 7 1000
2012 8 6000
2012 9 9000
2012 10 4000
我想要那个:
YEAR WEEKS VALUE
2012 1 ( Average value for week 49, 50, 51, 52 for the year 2011)
2012 2 ( Average value for week 50, 51, 52 for the year 2011 and week 1 for the year 2012)
2012 3 ( Average value for week 51, 52 for the year 2011 and week 1, 2 for the year 2012)
2012 4 ( Average value for week 52 for the year 2011 and week 1, 2, 3 for the year 2012)
2012 5 5250 -> ( Average value for week 1, 2, 3 , 4 for the year 2012)
2012 6 6500 -> ( Average value for week 2, 3 , 4, 5 for the year 2012)