title: Calculate the average of the rolling last 4 weeks
body: <p>I need your help.</p>
  
  <p>Database: SQL SERVER 2008R2</p>
  
  <p>I want to calculate for a year and a week the average of value of the 4 last weeks.</p>
  
  <p>I have data a table like that:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>And I want that:</p>
  
  <pre><code>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 -&gt; (  Average value for  week 1, 2, 3 , 4 for the year 2012)
  2012        6          6500 -&gt; (  Average value for  week 2, 3 , 4, 5 for the year 2012)
  </code></pre>