title: How to sort by count with postgresql?
body: <p>I have two tables:</p>
  
  <pre><code>Companies: (id, name, city)
  Workers: (id, name)
  </code></pre>
  
  <p>I would like to get all companies and sort them by numbers of employes.</p>
  
  <p>The result should give:</p>
  
  <pre><code>count | company id | company name | city
  ------------------------------------------
  90         6           foo corp      NY
  45         9           bar corp      LA
  0          3         foobar corp     HO
  </code></pre>
  
  <p>I tried:</p>
  
  <pre><code>select 
      c.*, 
      count(w.id) as c 
  from 
      companies c 
  left join 
      workers w 
  on 
      c.id = w.company_id 
  group by 
      c.id 
  order by 
      c desc;
  </code></pre>
  
  <p>But that's not working as it tells me to group by g.name too :/</p>
  
  <p>Any ideas?</p>