title: MySQL count unique and duplicate values
body: <p>I need some help with counting both unique and duplicate values in MySQL. I want to know how many records there are total, and also how many is there two times and three times and so on...</p>
  
  <p>Do I need to use <code>UNION</code> or something? I think <code>SUM</code> would be the best solution for me because of I might use some joins with this in future.</p>
  
  <p>Sample data:</p>
  
  <pre><code>| custId | name   |
  |--------|--------|
  | 1001   | Alex   |
  | 1001   | Alex   |
  | 1002   | Daniel |
  | 1003   | Mark   |
  | 1002   | Daniel |
  </code></pre>
  
  <p>Sample results:</p>
  
  <pre><code>| total | twoTimes | threeTimes |
  |-------|----------|------------|
  |     3 |        2 |          0 |
  </code></pre>
  
  <p>Thanks in advance.</p>