PL/SQL 中是否忽略了 Case When 语句的 Else 部分?

Is the Else part of Case When statement ignored in PL/SQL?

为什么 "else" 部分不起作用我不明白。如果没有提供 case 语句,通常它应该 returns 反转数字。

这是我的代码;

select Id,
       case 
         when mod(Id,10)<(Id/10) 
           then (cast((Id/10) as number(5))*10)+(mod(Id,10)) 
         else 
           mod(Id,10)*10+(Id/10)  
       end Col
from digits

示例数据;

CREATE TABLE Test
(
    Id INT
);

insert into test
select 21 from dual
UNION ALL
select 12 from dual
UNION ALL
select 34 from dual
UNION ALL
select 43 from dual
UNION ALL
select 29 from dual
UNION ALL
select 92 from dual;

提前致谢..

为了用两位数字反转整数,case 应该看起来像(注意 trunc 函数):

select  
   Id,
   case 
     when mod(Id,10)<(Id/10) 
       then trunc(Id/10)*10+mod(Id,10) --this is the number itself, Id
     else 
       mod(Id,10)*10+trunc(Id/10)  --reverse :)
   end Col

@aprkturk 你提到了 T-SQL;这是弗洛林的回答翻译:

select  
   Id,
   case 
     when Id % 10 < Id / 10
       then Id / 10 * 10 + Id % 10  -- this is the number itself, Id
     else 
       Id % 10 * 10 + Id / 10       -- reverse :)
   end Col
from @i
order by Id

这是做什么用的?想要做的事情似乎很奇怪...