Você pode criar uma lista de intervalos usando
UNION ALL
e LEFT JOIN
com isso:SELECT CONCAT(IFNULL(ranges.min, '∞'), '-', IFNULL(ranges.max, '∞')) AS `range`, avg(value) AS avg
FROM (
SELECT 0 AS min, 21 AS max UNION ALL
SELECT 21, 34 UNION ALL
SELECT 34, 64 UNION ALL
SELECT 64, NULL
) AS ranges
LEFT JOIN t ON (ranges.min IS NULL OR value >= ranges.min) AND
(ranges.max IS NULL OR value < ranges.max)
GROUP BY ranges.min, ranges.max
Observe que a consulta acima colocará
20.9999
dentro de [0-21)
e 21.0000
dentro de [21-34)
variar.