如果 A、B为NULL或者B为0,那要有什么结果啊??

解决方案 »

  1.   

    如果 A、B为NULL或者B为0 那c就为null
      

  2.   

    C=decode(NVL(B,0),0,NULL,NVL(A,0)/B)
      

  3.   

    谢谢qiaozhiwei(乔).
    上面的条件改为:如果 A、B为NULL或者B<=0, 那c就为null
      

  4.   

    c=decode(nvl(sign(abs(a)*b),0),0,null,-1,null,a/b)
      

  5.   

    感觉最好这样update tb set c=null where c is not null;
    update tb set c=a/b where b>0;好象这样的效率应该最好
      

  6.   

    ORARichard(没钱的日子......) 说的对,后面的效率要高
      

  7.   

    update table1  set c=
    case when  a is null  then  null
         when  b is null  then  null
         when  b =0       then  null
         else   a/b
    end  ;
      

  8.   

    case when 不是sqlserver中的吗? oracle也有吗?
      

  9.   

    >=9I,肯定行
    8I 没试过,可能行
    <8I 肯定不行