title: MS ACCESS count/sum number of rows, with no duplicates
body: <p>I have the following table which I need to count the total number of rows without including any duplicate records.</p>
  
  <pre><code>CustomerID
  test1
  test1
  test2
  test3
  test4
  test4
  </code></pre>
  
  <p>As you can see, the total number of rows is 6 but there are two test1 and two test4, and I wish the query to return 4.  IOW, I want to count unique values in <code>CustomerID</code>.</p>
  
  <p>I've tried sub query but didn't get it to work for me.</p>
  
  <p><strong>-- Update 27/06/2012 --</strong></p>
  
  <p>Thanks, both worked for me:</p>
  
  <blockquote>
    <ol>
    <li>SELECT COUNT(*) FROM ( SELECT CustomerID FROM TheTable GROUP BY CustomerID ) as</li>
    <li>SELECT COUNT(*)
    FROM
    (
        SELECT DISTINCT CustomerID FROM TheTable
    ) AS sub;</li>
    </ol>
  </blockquote>
  
  <p>I now need a query to keep only those CustomerID which were added today, then count them. </p>
  
  <p>For example,</p>
  
  <pre><code>CustomerID DateAdded
  test1 25/06/2012
  test1 25/06/2012
  test2 26/06/2012
  test3 27/06/2012 - Today
  test4 27/06/2012 - Today
  test4 27/06/2012 - Today
  </code></pre>
  
  <p>then it needs to return 3.</p>
  
  <p>I've tried adding in the following query into the two solutions provided, but couldn't get either of them to work/return the value I want.</p>
  
  <blockquote>
    <p>HAVING (([TheTable].DateAdded)=Date());</p>
  </blockquote>