title: SQL query to get count of each fileid entry in table
body: <p>I Have a table like given below, the table name is <code>tag</code>.</p>
  
  <pre><code>id fileid 
  == ======
   1   1
   2   2
   3   2
   4   2
   5   3
   6   3
   7   3
  </code></pre>
  
  <p>I need to find the number of occurrences of each <code>fileId</code>. So the output need to be something like this:</p>
  
  <pre><code>fileId count
  ====== =====
    1      1
    2      3
    3      3
  </code></pre>
  
  <p>Can somebody help me with writing this MySQL query?</p>