Consider the following query:
select
max(registeredYear) as year,
count(case when gender='Male' then 1 end) as male_cnt,
count(case when gender='Female' then 1 end) as female_cnt,
count(*) as total_cnt
from student
where registeredYear = 2013
group by registeredYear;
The result will be like this:
Year male_cnt female_cnt total_cnt
---- -------- ---------- ---------
…
Top comments (0)