title: how to get duplicate count and the corresponding value postgresql
body: <p>I have a table called <em>duptable</em> and which contains following <em>data</em>.</p>
  
  <pre><code>mid mgp
  
  1  cat    
  1  cat1    
  1  cat2    
  1  cat3    
  1  cat4    
  2  rat    
  3  bat    
  3  bat1    
  3  bat2    
  3  bat3
  </code></pre>
  
  <p>as you can see in the above table mid 1 repeats 5 times and mid 3 repeats 4 times.How can I get result like below</p>
  
  <pre><code>  mid dup_count
      1  5
      3  4
  </code></pre>