Skip to content
Advertisement

How to write a query to produce counts for arbitrary value bands?

My table had 3 fields: id and unit. I want to count how many ids have <10, 10-49, 50-100 etc units. The final result should look like:

This is the query that returns each id and how many units it has:

How can I build on that query to give me the category, countIds result?

Advertisement

Answer

edit: changed sum() to count() above.

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