📜  mysql 按范围分组 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:27.689000             🧑  作者: Mango

代码示例1
select 
  case 
    when RESULT between 0 and 50 then '0-50'
    when RESULT between 50 and 100 then '51-100'
    when RESULT between 100 and 150 then '101-150'
    when RESULT between 150 and 200 then '151-200'
    when RESULT between 200 and 250 then '201-250'
    else 'OTHERS'
  end as `Range`,
  count(1) as `Count`
from PERSON
group by `Range`;