select x.范围, count(*)
from (select t.ename,
case
when t.sal <= 1000 then
'0-1000'
when t.sal <= 2000 then
'1000-2000'
when t.sal <= 3000 then
'2000-3000'
when t.sal <= 4000 then
'3000-4000'
when t.sal <= 5000 then
'3000-4000'
ELSE
'太高'
END as 范围
from emp t) x
group by x.范围
order by x.范围;