这个要看你的区间是等距区间还是自定义灵活区间
select floor(price/10),avg(price) from 表 group by floor(price/10);
select
case
when price <10 then '低于10元'
when price >=10 and price <30 then '10~29.9元'
else '30元及以上'
end ,
avg(price) from 表
group by
case
when price <10 then '低于10元'
when price >=10 and price <30 then '10~29.9元'
else '30元及以上'
end;
你要评分的平均值,把avg函数后面的字段换成评分就行了
avg(score)