Skip to content
Advertisement

SQL Data range using Case

I have table1 with data

and my query

The result

How do I want to see the result like this ( missing 40-49 with count 0 and above 60+ count 0)

Thank you for your help.

Advertisement

Answer

You can enumerate the ranges with row_constructor values(), then bring the table with a left join, and finally aggregate:

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