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

Count number of applications that received a decision by their category?

My table has 4 columns in it.

status: (This is a string that is either pended, accepted, or rejected value of P, A, or R)
source: (this is a code like BBQ5)
id: (this is a unique identifier number)

So a row would be something like

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

Accepted GBBG 2109202

I want to order them by how many got accepted/ rejected / pended per source

I came up with this.

SELECT status , count(status)
FROM myTable
WHERE source in  (
'BB5',
'GGG',
'FEV'
)
GROUP BY status

this gives me the number of rejected count but I need it specified per code is this possible in sql ?

>Solution :

use a case when for the Status categories

SELECT 
source,
sum(case when status='accepted' then 1 end) accepted_count,
sum(case when status='rejected' then 1 end) rejected_count
FROM myTable
WHERE source in  (
'BB5',
'GGG',
'FEV'
)
group by source
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