title: SQL Daily Outstanding Sales, Rolling Aggregate?
body: <p>With the below test data I am trying to show how many sales have not been actioned by a colleague, an outstanding sale is any record that is still showing as "New", I have been using the below to identify those.</p>
  
  <pre><code>select saleID, count(*) group by saleID having count(*)=1
  </code></pre>
  
  <p>The trouble I have is that I find it easy to show <strong>overall</strong> how many are still outstanding <strong>to date</strong> but I can't figure out how to show how many were outstanding say 3 days ago. The idea is that this will show a trend when charted daily which will highlight if there has been an increase/decrease of outstanding sales by the end of each day. Ideally the output would be along the lines of the below</p>
  
  <pre><code>   Date      VolumeOutstanding 
  2020-01-01    0
  2020-01-02    1
  2020-01-03    3
  2020-01-04    2    
  </code></pre>
  
  <p><strong>DataSet</strong></p>
  
  <pre><code>SaleID   Date         Outcome
  1        2020-01-01   New
  1        2020-01-01   Complete
  2        2020-01-01   New
  2        2020-01-02   Complete
  3        2020-01-03   New
  4        2020-01-03   New
  5        2020-01-03   New
  5        2020-01-04   Complete
  </code></pre>