0

sample database

Above is my participants table and my problem is I want to count how many male and female are the same type of participant. Below is the code I have that count how many participant per type.

SELECT type_parti, COUNT(1) FROM tbl_participants GROUP BY type_parti
propaganja
  • 123
  • 4
  • 13

1 Answers1

1

Use a conditional sum

SELECT type_parti, 
       sum(sex = 'm') as males,
       sum(sex = 'f') as females 
FROM tbl_participants 
GROUP BY type_parti
juergen d
  • 201,996
  • 37
  • 293
  • 362