Skip to content
Advertisement

Mysql Group By age by range [closed]

i need help, i need to create report like this

the report is group by the age, but i can’t get when age under <= 13 to inside in 13 age, this is my query, it’s only work for same value, how to add value under 13 to be inside 13 age.

please help me for this, and sorry for bad english

Advertisement

Answer

I would use a range comparison; this works by defining a start and end value in the union all derived table; then you can use between to put the users in groups. We can also provide a description for each range, that we will use in the outer query:

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