Może właśnie tego chcesz:
SELECT
5 * (n div 5) as 'from',
5 * (n div 5) + 4 as 'to',
COUNT(*)
FROM yourtable
GROUP BY n div 5;
Dla Twojej próbki to zapytanie daje Ci
+------+------+----------+
| from | to | count(*) |
+------+------+----------+
| 0 | 4 | 3 |
| 5 | 9 | 4 |
| 10 | 14 | 2 |
| 15 | 19 | 1 |
+------+------+----------+
4 rows in set (0.00 sec)