3)Find the ratio / mix of students by gender in each class
There is a table students -
Columns are - name , class , dob , gender , marks
SELECT class,
COUNT(IF(gender = 'male', 1, NULL)) count_male,
COUNT(IF(gender = 'female', 1, NULL)) count_female,
COUNT(IF(gender = 'male', 1, NULL))/COUNT(IF(gender = 'female', 1, NULL)) as ratio
FROM
students
group by class ;
Comments
Post a Comment