Mysql 查询 多条件判断

2022-09-20  本文已影响0人  Super淳语
条件:
1、>=90:优秀
2、>=80:良好
3、>=60:及格
4、<60:不及格

执行:
select id as 学号, name as 姓名, score as 分数,   
(  
  case  
    when score >= 90 then '优秀' 
    when score >= 80 and score < 90 then '良好' 
    when score >= 60 and score < 80 then '及格' 
    when score < 60 then '不及格' 
  end 
)  
as 等级  
from scores;

上一篇 下一篇

猜你喜欢

热点阅读