title: TSQL Running Sum
body: <p>I need to show inventory levels for each day in a view. I have one table that lists the current item and quantity and another table that has all of the transactions that happened to those items. I need to create a query that lists the item, date and inventory level for that date for a trend report. Here would be some sample data in the tables:</p>
  
  <p>Items:</p>
  
  <pre><code>ItemNumber     QuantityOnHand
  ----------     --------------
  B34233         25.0
  B34234         10.0
  </code></pre>
  
  <p>ItemTransactions:</p>
  
  <pre><code>TransDate      ItemNumber     Quantity
  -----------    ----------     --------
  1/1/2011       B34233         10.0
  1/2/2011       B34234         -15.0
  1/2/2011       B34233         -5.0
  1/4/2011       B34234         -10.0
  </code></pre>
  
  <p>Here is the outcome I want from the query:</p>
  
  <pre><code>Date          ItemNumber      Quantity
  ----          ----------      --------
  12/31/2010    B34233          20.0
  12/31/2010    B34234          35.0
  1/1/2011      B34233          30.0
  1/1/2011      B34234          35.0
  1/2/2011      B34233          25.0
  1/2/2011      B34234          20.0
  1/3/2011      B34233          25.0
  1/3/2011      B34234          20.0
  1/4/2011      B34233          25.0
  1/4/2011      B34234          10.0
  </code></pre>
  
  <p>How would I write this query? I have pretty good knowledge of TSQL but cannot come up with a way to write this query.</p>