--原始查询:
select * from student
结果
使用 case when 查询示例1:
select
sno
,cno
,score
,case when score <60 then '不及格'
when score >=60 and score <70 then '及格'
when score >=70 and score <80 then '中等'
when score >=80 and score <90 then '良好'
when score >=90 and score <100 then '优秀'
else '0'
end as 等级
from sc order by score asc
结果
使用 case when 示例2:
select
sno
,cno
,case cno when 'X003' then '语文'
when 'C001' then '数学'
when 'E002' then '英语'
when 'C004' then '日语'
else ''
end as 课程名称
,score
from sc
结果