I have a list of people and I have to display the count of both male and female entries.
SELECT COUNT(gender)
FROM people a
JOIN accounts b
ON b.idpers = a.idpers
JOIN cards c
ON c.nrc = b.nrc
WHERE c.category = 'CREDIT'
AND a.gender = :gender
I have tried this and it works, but I want it to display the number of male and female at the same time without the prompt input. Any ideas?
>Solution :
You could do this by group by gender. Here is how you could do this
SELECT gender,COUNT(gender)
FROM people a
JOIN accounts b ON b.idpers=a.idpers
JOIN cards c ON c.nrc=b.nrc
WHERE c.category= 'CREDIT' group by gender;