title: Select distinct values with count in PostgreSQL
body: <p>This is a heavily simplified version of an SQL problem I'm dealing with. Let's say I've got a table of all the cities in the world, like this:</p>
  
  <pre><code>country city
  ------------
  Canada  Montreal
  Cuba    Havanna
  China   Beijing
  Canada  Victoria
  China   Macau
  </code></pre>
  
  <p>I want to count how many cities each country has, so that I would end up with a table as such:</p>
  
  <pre><code>country city_count
  ------------------
  Canada  50
  Cuba    10
  China   200
  </code></pre>
  
  <p>I know that I can get the distinct country values with <code>SELECT distinct country FROM T1</code> and I suspect I need to construct a subquery for the city_count column. But my non-SQL brain is just telling me I need to loop through the results...</p>
  
  <p>Thanks!</p>