I have simple table student which contains two column names and gender as m or f.
I have to count number of male and female in table and display it into tow different columns .
Result should be like:
|Male |female | | 5 | 4 |
Advertisement
Answer
I don’t know m
but standard SQL for this would be :
SELECT SUM(CASE gender WHEN 'm' THEN 1 ELSE 0 END) AS Male, SUM(CASE gender WHEN 'f' THEN 1 ELSE 0 END) AS Female FROM student