title: count unique values in a group, and exclude already counted rows in mysql
body: <p>I would like to count all unique visitors group by day.But i want to exclude the visitor if he has already visited any previous day.My sample table is as below</p>
  
  <pre><code>mysql&gt; select * from visitor;
  +-------+------------+--------------+
  | user  | visit_date | No Of Visits |
  +-------+------------+--------------+
  | user1 | 20150101   | 10           |
  | user2 | 20150102   | 1            |
  | user3 | 20150101   | 1            |
  | user1 | 20150102   | 2            |
  +-------+------------+--------------+
  </code></pre>
  
  <p>My requirement is to get a distinct count of user group by visit date but to exclude already visited user.</p>
  
  <p>20150101 --> User1 and user 3 visited</p>
  
  <p>20150102 --> User 2 visited (Exclude user1 as he has already visited)</p>
  
  <pre><code>+----------------------+------------+
  | count(distinct user) | visit_date |
  +----------------------+------------+
  |                    2 | 20150101   |
  |                    1 | 20150102   |
  +----------------------+------------+
  </code></pre>