Skip to content
Advertisement

SQL Query count of values

I’m trying to write a query that will show the number of times some specific values are present per node

Here is my table:

I’m trying to query the count of nodes for the number of times the values in channel_width show up. For instance, the amount of nodes ’32’ show up once and ’64’ shows up 3 times, the amount of nodes ’64’ shows up all 4 times but ’32’ never shows up, etc. Ultimately, I’m trying to get the count of nodes for each circumstance per host_name. If the value doesn’t show up, I don’t want it counted as part of the count.

This is what I tried but its showing the count the same across the board which isn’t right…

Thanks!

EDIT: expected results:

Advertisement

Answer

Please try this out

Check the db fiddle here

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