title: Calculating percentage within a group
body: <p>given a table that for the following commands:</p>
  
  <pre><code>select sex, count(*) from my_table group by sex;
  select sex, employed, count(*) from my_table group by sex, employed;
  </code></pre>
  
  <p>gives:</p>
  
  <pre><code>  sex  | count 
  -------+------
  male   | 1960 
  female | 1801
  </code></pre>
  
  <p>and:</p>
  
  <pre><code> sex     | employed | count 
  ---------+----------+-------
   male    | f        |  1523 
   male    | t        |   437 
   female  | f        |  1491 
   female  | t        |   310 
  </code></pre>
  
  <p>I'm having a difficulty writing a query that will calculate percentage of employed within each sex group. So the output should look like this:</p>
  
  <pre><code> sex     | employed | count  | percent
  ---------+----------+--------+-----------
   male    | f        |  1523  | 77.7% (1523/1960)
   male    | t        |   437  | 22.3% (437/1960)
   female  | f        |  1491  | 82.8% (1491/1801)
   female  | t        |   310  | 17.2% (310/1801)
  </code></pre>