Skip to content
Advertisement

SQL – count function not working correctly

I’m trying to count the blood type for each blood bank I’m using oracle DB the blood bank table is created like this

when I use the count function

the result would be like this

enter image description here

so why the count function is not working correctly? I’m trying to display each blood bank blood type count which is not only one in this case

Advertisement

Answer

You should normalize your data and get each blood type value onto a separate record. That is, your starting data should look like this:

With this data model, the query you want is something along these lines:

Or, if you want just counts of types across all bloodbanks, then use:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement