decode函数里面的默认值怎么设置啊?

解决方案 »

  1.   


    select decode(DEPTNAME,null,'1',DEPTNAME) from test2 where 1=1 and case when DEPTNAME is not null then DEPTNAME!='1' else 1=1 end ;这是我原来写的一条sql语句,里面的decode的最后一个值就是默认值,DEPTNAME为null的时候,返回'1',不为null的时候返回DEPTNAME值。
      

  2.   

    decode语法
    decode(判断条件,条件1,结果1,条件2,结果2,默认结果)