title: How to count the distinct column in mysql?
body: <p>E.g:</p>
  
  <p>with the <code>select query</code> I got below result:</p>
  
  <pre><code>columnA columnB
  type1   typea
  type2   typea
  type3   typeb
  type4   typec
  type5   typed
  type6   typed
  type7   typed
  </code></pre>
  
  <p>with the <code>DISTINCT</code> I only got the <code>distinct result</code>,but I also want to get the <code>total number</code> of each distinct.</p>
  
  <p>and now I want to get the <strong>total number</strong> of</p>
  
  <pre><code>typea,typeb,typec and typed.
  </code></pre>
  
  <p>Just like:</p>
  
  <pre><code>columnB total
  typea   2
  typeb   1
  typec   1
  typed   3
  </code></pre>
  
  <p>Thank you very much!!</p>