Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to display two counts using oracle databases?

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading