title: mysql - query to calculate percentage of genders
body: <p>In the below table, i need top 2 city's based on count. Also needed  latitude, longtude for that 2 citys which are given in table. male percent, fem percent to be calculated seperately.</p>
  
  <pre><code>+-------+---------+--------+-----+------+
  | name  | city    | gender | lat | long |
  +-------+---------+--------+-----+------+
  | jon   | nyc     | m      | 40  | 74   |
  | kat   | dallas  | f      | 32  | 96   |
  | kay   | la      | m      | 34  | 118  |
  | jim   | chicago | f      | 41  | 87   |
  | joy   | nyc     | f      | 40  | 74   |
  | kelly | dallas  | f      | 32  | 96   |
  | lind  | chicago | m      | 41  | 87   |
  | tyson | nyc     | m      | 40  | 74   |
  | bush  | dallas  | f      | 32  | 96   |
  | will  | chicago | m      | 41  | 87   |
  | sony  | la      | f      | 34  | 118  |
  | graph | la      | f      | 34  | 118  |
  | mike  | la      | m      | 34  | 118  |
  | pele  | chicago | m      | 41  | 87   |
  | mony  | la      | f      | 34  | 118  |
  +-------+---------+--------+-----+------+
  </code></pre>
  
  <p>Desired Output:</p>
  
  <pre><code>+---------+-----+------+-----------+----------+
  | city    | lat | long | male_perc | fem_perc |
  +---------+-----+------+-----------+----------+
  | la      | 34  | 118  | 40        | 60       |
  | chicago | 41  | 87   | 75        | 25       |
  +---------+-----+------+-----------+----------+
  </code></pre>