select 单量,count(*) as 客户数
from(select *,case when 单总<=5 then '0-5'
when 单总<=10 then '6-10'
when 单总<=20 then '11-20'
else '20以上'
end as 单量
from
(select 客户id,count(distinct 运单号) as 单总
from 快递揽收表
where date_format(创建日期,'%Y-%m')='2020-05'
group by 客户id) as new1) as new2
group by 单量
order by 单量 asc;