Måske er dette, hvad du ønsker:
SELECT
5 * (n div 5) as 'from',
5 * (n div 5) + 4 as 'to',
COUNT(*)
FROM yourtable
GROUP BY n div 5;
For dit eksempel giver denne forespørgsel dig
+------+------+----------+
| from | to | count(*) |
+------+------+----------+
| 0 | 4 | 3 |
| 5 | 9 | 4 |
| 10 | 14 | 2 |
| 15 | 19 | 1 |
+------+------+----------+
4 rows in set (0.00 sec)