Oracle中两个case的区别

xiaoxiao2026-06-07  8

select autoid,stu_id, sub_id, score from t_score

AUTOID STU_ID SUB_ID SCORE 1 S0001 SUB001 90.00 2 S0002 SUB001 80.00 3 S0001 SUB002 50.00 4 S0002 SUB002 20.00 5 S0003 SUB002 0.00 6 S0003 SUB001 85.00 7 S0001 SUB001 80.00 8 S0002 SUB001 66.00

要求:85以上显示为“优秀”,60以下为“不及格”,其它为“及格”。 SQL语句为: select autoid,stu_id, sub_id, score, (case     when score>=85 then '优秀'     when score<60  then '不及格'     else '及格'   end ) memo from t_score

语法: (case when ? then ? else ? end)

★注意:结束是“End”。 ★区别于存储过程中的case分支语句,语法为: Case   When (...) Then        ...;   When (...) Then        ...;   Else ...; End Case; ★注意:结束是“End Case”。在项目中的实例:   n1:=1;--动态计算   n2:=3;--动态计算   case      when (n1-n2)<0 then str:='名次上升';     when (n1-n2)>0 then str:='名次下降';     else str:='名次不变';   end case;

<!--v:3.2-->

相关资源:敏捷开发V1.0.pptx
转载请注明原文地址: https://www.6miu.com/read-5049738.html

最新回复(0)