Brug bare group by
:
select (case when distance <= 100 then 'group 1'
when distance <= 1000 then 'group 2'
else '!?!'
end) as range_group,
max(rate)
from t
group by (case when distance <= 100 then 'group 1'
when distance <= 1000 then 'group 2'
else '!?!'
end);