The title explains my whole question. Here’s the query:
select
date_format(now(), '%Y') - date_format(date_of_birth, '%Y') age,
IF(date_format(now(), '%Y') - date_format(date_of_birth, '%Y') < 18,
'Under 18',
IF(date_format(now(), '%Y') - date_format(date_of_birth, '%Y') <= 24,
'19 to 24',
IF(date_format(now(), '%Y') - date_format(date_of_birth, '%Y') <= 34,
'25 to 34',
'Over 34'))) age_range
from customer
I suggest a combination of case and a nested query – something like: