When I do this,
SELECT id, gender, count(1)
FROM class_student
WHERE id = 1
GROUP BY gender
I get
id gender count
--------------------
1 female 10
1 male 5
How can I get this?
id female male
---------------
1 10 5
Is following query is the right way to do this?
SELECT
id,
(select count(1) from class_student
where id = 1 AND gender='female') AS female,
(select count(1) from class_student
where id = 1 AND gender='male') AS male
FROM class_student
GROUP BY id