56,681
社区成员
发帖
与我相关
我的任务
分享
select
concat( floor((score-1)/10) * 10 + 1, '-', floor((score-1)/10) * 10 + 9) as score,
count(*) `count`
from
t1
group by
floor((score-1)/10)
select
'count' as score,
sum(case when score between 1 and 10 then 1 else 0 end) as `1-10`,
sum(case when score between 11 and 20 then 1 else 0 end) as `11-20`,
sum(case when score between 21 and 30 then 1 else 0 end) as `21-30`,
sum(case when score between 31 and 40 then 1 else 0 end) as `31-40`,
sum(case when score between 41 and 50 then 1 else 0 end) as `41-50`
from t1_1