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

京公网安备 11010502036488号