将scott.emp 表的工资划分等级:
大于0 小于等于1500 的划分为“一级工资”
大于1500 小于等于3000 的为“二级工资”
大于3000 小于等于4500 的为“三级工资”
其他的为“四级工资”
请用 case when 和decode 两种方式查询。
--case when方式:
select ename,sal,case when sal>0 and sal<=1500 then "一级工资"
when sal >1500 and sal<=3000 then "二级工资"
when sal >3000 and sal <=4500 then "三级工资"
else "四级工资" end "工资等级"
from emp order by sal desc;
--decode方式:
select ename,sal,decode(ceil(sal/1500),1,"一级工资",
2,"二级工资",
3,"三级工资",
"四级工资") as "工资等级"
from emp
order by sal desc;