title: SQL sum 12 weeks of data based on first sold date across different items
body: <p>The database has thousands of individual items, each with multiple first sold dates and sales results by week. I need a total sum for each products first 12 weeks of sales.</p>
  
  <p>Code was used for previous individual queries when we know the start date using a SUM(CASE. This is too manual though with thousands of products to review and we are looking for a smart way to speed this up.</p>
  
  <p>Can I build on this so the sum find the minimum first shop date, and then  sums the next 12 weeks of results? If so, how do I structure it, or is there a better way?</p>
  
  <p>Columns in database I will need to reference with sample data</p>
  
  <p>PROD_ID | WEEK_ID | STORE_ID | FIRST_SHOP_DATE | ITM_VALUE</p>
  
  <p>12345543 | 201607 | 10000001 | 201542 | 24,356</p>
  
  <p>12345543 | 201607 | 10000002 | 201544 | 27,356</p>
  
  <p>12345543 | 201608 | 10000001 | 201542 | 24,356</p>
  
  <p>12345543 | 201608 | 10000002 | 201544 | 27,356</p>
  
  <p>32655644 | 201607 | 10000001 | 201412 | 103,245</p>
  
  <p>32655644 | 201607 | 10000002 | 201420 | 123,458</p>
  
  <p>32655644 | 201608 | 10000001 | 201412 | 154,867</p>
  
  <p>32655644 | 201608 | 10000002 | 201420 | 127,865</p>