title: Dividing count on one table from another and grouping the results
body: <p>I am trying to calculate the ratio of rows in table A to rows in table B. This would have been easy if I only had to calculate the ratio for the whole sets, but I want to group them by a category that exists in table B.
  Table A and B are linked through a primary key (id).</p>
  
  <p>Edit:</p>
  
  <p>I tried the following:</p>
  
  <pre><code>select
      (select count(*) from class_a a left join football_players b on (b.id = a.id) group by age)
      /
      (select count(*) from football_players group by age)
  </code></pre>
  
  <p>but the group by command does not work here.</p>