当我进入星期一,它需要显示1&为12岁

时间:2016-12-01 05:14:34

标签: mysql sql oracle

select &enter,
       case 
           when enter=mon then '1'
           when enter=yr then '12'
           else '0'
       end as status
from dual

1 个答案:

答案 0 :(得分:1)

基于原始代码:

select '&enter',
       case 
           when '&enter'='mon' then '1'
           when '&enter'='yr' then '12'
           else '0'
       end as status
from dual

建议代码:

select '&enter',
       case '&enter'
           when 'mon' then 1
           when 'yr'  then 12
           else 0
       end as status
from dual