title: Msql: Counting growth over time
body: <p>I posted about this a few weeks ago, but I don't think I asked the question clearly because the answers I got were not what I was looking for.  I think it's best to start again.</p>
  
  <p>I'm trying to query a database to retrieve the number of unique entries over time.  The data looks something like this:    </p>
  
  <p><code>Day</code> | <code>UserID</code><br>
  1   | A<br>
  1   | B<br>
  2   | B<br>
  3   | A<br>
  4   | B<br>
  4   | C<br>
  5   | D</p>
  
  <p>I'd like the query result to look this this</p>
  
  <p>Time Span      | COUNT(DISTINCT <code>UserID</code>)<br>
  Day 1 to Day 1 |  2<br>
  Day 1 to Day 2 |  2<br>
  Day 1 to Day 3 |  2<br>
  Day 1 to Day 4 |  3<br>
  Day 1 to Day 5 |  4  </p>
  
  <p>If I do something like </p>
  
  <pre><code>SELECT COUNT(DISTINCT `UserID`) FROM `table` GROUP BY `Day`
  </code></pre>
  
  <p>, the distinct counts will not consider user IDs of previous days.</p>
  
  <p>Any Ideas?  The data set I'm using is quite large, so multiple-queries and post processing takes a long time (that's how I'm currently doing it).</p>
  
  <p>Thanks</p>