In the table below, i need to find the percentage of males who are in the state 'nyc'.
select count(*) from table where state = 'nyc' and gender = 'male';
gives me the count of males from nyc. I need the % of males from nyc as 75%.
+-------+-------+--------+
| name | state | gender |
+-------+-------+--------+
| Jon | nyc | male |
+-------+-------+--------+
| obama | LA | male |
+-------+-------+--------+
| kat | nyc | male |
+-------+-------+--------+
| andy | nyc | male |
+-------+-------+--------+
| sri | nyc | female |
+-------+-------+--------+
desired output:
state, male_percentage--> nyc, 75 %
as 3 are males and 1 is female from total 4 from nyc.