title: Count the same values in column SQL Server
body: <p>I want to make that my query would count same values in column, and then would order by descending order. My code does not work :/.</p>
  
  <pre><code>SELECT 
      F_PURCHASE.PID, D_PITEMS.ID, COUNT(D_PITEMS.ITEMID), D_PITEMS.ITEMNAME 
  FROM 
      F_PURCHASE 
  INNER JOIN 
      D_PITEMS ON F_PURCHASE.PID = D_PITEMS.ID 
  GROUP BY 
      D_PITEMS.ITEMID
  </code></pre>
  
  <p>Any suggestions? </p>