2
I would like to tabulate customers registered in a database mysql
by age range.
I have a field nascimento
guy date
.
With the consultation below I can group by birth.
SELECT COUNT(*) AS qtd, YEAR(FROM_DAYS(TO_DAYS(NOW())-
TO_DAYS(nascimento))) AS idade FROM cliente GROUP BY nascimento ASC ORDER BY qtd DESC
But I return the amount only to the exact age of group by
, would like an interval count (example below):
30 - 20~25 anos
20 - 25~30 anos
10 - 30~35 anos
How to adjust the above query so that it presents this type of answer?
It worked beautifully, thank you!
– Pedro Augusto