title: Calculate a growth ratio week over week in SQL Statement
body: <p>I have a SQL Server table contains [date], [category], [year], [week], [Month], [Volume Received].</p>
  
  <p>Here's the query I wrote for getting weekly sum[Volume] per category for last 4 years.</p>
  
  <pre><code>    SELECT Year([Date]) AS [D_Year]
         , [Week] AS [Week of Year]
         , SUM([Volume Received])AS [Received]
         , [Category]
    FROM [t1]
    WHERE YEAR(Date) in ('2016', '2017', '2018','2019')
  
    GROUP BY Year([Date]), [Week], [Category]
  </code></pre>
  
  <p>It give me this table:</p>
  
  <pre><code> &gt; year   week      received     category  
   &gt; 2016     1         51123         A 
   &gt; 2016     2         41123         A 
   &gt; 2016     3         21123         B 
   &gt; 2016     1         5113          D 
   &gt;  ...
   &gt; 2017     18         1113         A
   &gt;  ...
   &gt; 2019     1         11134         C
  </code></pre>
  
  <p><strong>I'm looking for one SQL Statement that will give me average growth ratio by week per category.</strong></p>
  
  <p>I've done it manually in EXCEL but thats not updating when I refresh my connection to SQL Server.</p>
  
  <p>Final output I want is something like this:</p>
  
  <pre><code>&gt; week      ratio      category  
  &gt; 1         -0.05         A 
  &gt; 1          0.15         B 
  &gt; 1          0.02         C 
  &gt; 1         -0.25         D
  &gt; 2          0.25         A 
  &gt; 2         -0.15         B 
  &gt; 2          0.02         C 
  &gt; 2         -0.25         D
  </code></pre>