你要怎么嵌套?select decode(decode(sign(a),1,100),100,5)
from
(select 1 as a,'a' as b from dual
union select 2 ,'b' from dual
) a--上面是,第一次判断是否大于0,大于0的话,就变成100,
第二次再判断是否是100,如果是100,就变成5.

解决方案 »

  1.   

    怎样用Decode实现这样的逻辑 :
    if (x=1 and y =2 )
         return 1
    else 
         return 2
      

  2.   

    用case when吧~ 
    这还是ANSI SQL呢, 拿到哪都能用
      

  3.   

    case    when 更好
      

  4.   

    select t.item_id,  (case  
         when t.item_id = '100006' then
           'OK'
         when t.item_id = '100005' then
           'NO'
         else
             'OOOO'
       end ) AS item_id  
      from tmpb_item_work  t
      

  5.   

    select decode(to_number(t.x||t.y),12,1,2) from table t
      

  6.   

    select decode(to_number(t.x||t.y),12,1,2) from table t