ORACLE中CASE语句输出等级制成绩

如题所述

以test表中数据为例:

其中90分及以上为优秀,70分-89分为良好,60-69分为及格,60分以下为不及格,可用如下语句给出等级制成绩:

select name,
       score,
       case
         when score >= 90 then
          '优秀'
         when score between 70 and 89 then
          '良好'
         when score between 60 and 69 then
          '及格'
         when score < 60 then
          '不及格'
       end ç­‰çº§
  from test;

查询结果:

温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-01-10
select id,
case when current_credits > 90 then '优'
when current_credits > 70 then '良'
when current_credits > 60 then '及格'
else '不及格'
end grade
from students本回答被网友采纳
第2个回答  2012-01-08
select id,
case when current_credits > 90 then 'a'
when current_credits > 80 then 'b'
when current_credits > 70 then 'c'
else 'd' end grade
from students追问

在PL/SQL中编程完成成绩判定功能:给出一个100之内的成绩,如果在90分以上则输出“优”,80-90分输出“良”,70-80
分输出“中”,60-70分输出“及格”,60分以下输出“不及格”。

追答

I think you can modify the sample SQL into PL/SQL

相似回答