title: How to limit the answers of the GROUP BY clause in sql-server (2005)
body: <p>I'm trying to get the top 50 cities for all customer lists in our DB
  (So simplified: every client has a list of customers with associated data(like the city))</p>
  
  <p>If I say: </p>
  
  <pre><code> SELECT top(50) clientid, city, COUNT(city) as cnt
   FROM customers
   GROUP BY clientid, city
   ORDER by cnt
  </code></pre>
  
  <p>it will limit the total resultset on 50 rows instead of limiting the results for every group.</p>
  
  <p>How can I get the top 50 per clientid?</p>
  
  <p>EDIT:
  I searched stackoverflow (and googled) but only found solutions for Mysql. Probably searching for 'limit' will only find mysql solutions wince thats the keyword needed for that Database engine. If I know the keyword needed in Sql-Server I could find it as well using google.</p>