title: Count unique ids in a rolling time frame
body: <p>I have a simple table as bellow with lots of IDs and dates. </p>
  
  <pre><code>ID      Date
  10R46   2014-11-23  
  10R46   2016-04-11  
  100R9   2016-12-21
  10R91   2013-05-03 
  ...     ...
  </code></pre>
  
  <p>I want to formulate a  query which counts the unique IDs for a rolling time frame of dates, for example ten days. Meaning that for each date it should give me the number of unique IDs between that date and 10 days back. Result should look something like this. </p>
  
  <pre><code>UniqueTenDays    Date
  200              2014-11-23 
  324              2014-11-24 
  522              2014-11-25
  532              2014-11-26 
  ...              ...
  </code></pre>
  
  <p>Something along the lines of the bellow but I realise I need to apply the WHERE clause and count the IDs for each Date somehow.</p>
  
  <pre><code>SELECT Date, COUNT(DISTINCT ID)
  FROM T 
  WHERE Date BETWEEN DATE_SUB(Date, INTERVAL 10 DAY) AND Date
  GROUP BY Date
  ORDER BY Date
  </code></pre>
  
  <p>Thanks in advance. </p>