I have two columns gender(values = 'Male' , 'Female') and grade(values = 'senior officer' , 'Junior Officer') and the table name is employee. I want to count all Males who are senior officers and all Males who are junior officers, vise versa for all females. Below is my code
''' SELECT staff_gender, staff_grade COUNT(*)
FROM permanent_staff
WHERE staff_gender='Female' AND staff_grade='senior officer' '''
CodePudding user response:
Aggregate.
SELECT staff_gender, staff_grade
, COUNT(*) AS total
FROM permanent_staff
GROUP BY staff_gender, staff_grade
ORDER BY staff_gender, staff_grade