title: Need to subtract until value reaches limit / predict when inventory runs out
body: <p>I am working on a query that has these two tables:
  Table A:</p>
  
  <pre><code>Store       NumItems
  1           500
  2           1000
  3           575 
  </code></pre>
  
  <p>Table B:</p>
  
  <pre><code>Store   Day             ItemsSold
  1       Monday          100
  1       Tuesday         200
  1       Wednesday       110
  1       Thursday        10
  1       Friday          1
  1       Saturday        140
  1       Sunday          90
  2       Monday          400
  2       Tuesday         150
  2       Wednesday       501
  2       Thursday        190
  2       Friday          600
  2       Saturday        180
  2       Sunday          21
  3       Monday          100
  3       Tuesday         1050
  3       Wednesday       108
  3       Thursday        102
  3       Friday          51
  3       Saturday        40
  3       Sunday          15
  </code></pre>
  
  <p>I need to be able to tell when the store will run out of items. I can get the date of the week that the process i ran, but I need to loop or somehow continue to subtract from each store and estate (Assume this is ran on Monday - store 1 will run out of Items on store 1 on Saturday, Store 2 will run out on Wednesday, store 3 will run out on Tuesday).</p>
  
  <p>thank you all for your help in advance !!! </p>