 <p><strong><a href="http://sqlfiddle.com/#!9/66a621/2" rel="nofollow">Sql Fiddle Demo</a></strong></p> <pre><code>SELECT g.country, g.gender, g.gender_count, (g.gender_count * 1.0 / c.country_count) * 100 FROM ( SELECT country, gender, count(*) as gender_count FROM YourTable GROUP BY country, gender ) g JOIN ( SELECT country, count(*) as country_count FROM YourTable GROUP BY country ) c ON g.country = c.country </code></pre>