You're welcome!类似的还有一个NVL(field_name,other_value)
if value of field_name is null then 
  return value
else
  return value of field_name
end if;

解决方案 »

  1.   

    sorry,if value of field_name is null then 
      return other_value
    else
      return value of field_name
    end if;
      

  2.   

    在oracle中实现if...else...的功能,除了decode外,还有一个case比较方便,呵呵:
    E:\oracle\ora92\database>sqlplus /nologSQL*Plus: Release 9.2.0.1.0 - Production on 星期五 1月 25 11:22:16 2002Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.SQL> conn lunar/lunar
    已连接。
    SQL> create table testcase
      2  (a char(6),
      3  b number(10),
      4  c char(9),
      5  d number(10,2),
      6  e char(20));表已创建。SQL> insert into testcase values('aa',110,'你好',100.2,'abc');已创建 1 行。SQL> insert into testcase values('bb',200,'大家好',120.25,'abcde');已创建 1 行。SQL> insert into testcase values('cc',150,'和平',50.9,'xyz');已创建 1 行。SQL> insert into testcase values('dd',170,'和平',200,'rst');已创建 1 行。SQL> insert into testcase values('ee',10,'公安部',21,'morning');已创建 1 行。SQL> commit;提交完成。SQL> select * from testcase;A               B C                  D E
    ------ ---------- --------- ---------- --------------------
    aa            110 你好           100.2 abc
    bb            200 大家好        120.25 abcde
    cc            150 和平            50.9 xyz
    dd            170 和平             200 rst
    ee             10 公安部            21 morningSQL> select a,b,(case when b>150 then '大于150'
      2     when b=150 then '等于150'
      3     when b<150 then '小于150'
      4     else '输入错误'
      5     end) as c, d,e
      6  from testcase
      7  /A               B C                 D E
    ------ ---------- -------- ---------- --------------------
    aa            110 小于150       100.2 abc
    bb            200 大于150      120.25 abcde
    cc            150 等于150        50.9 xyz
    dd            170 大于150         200 rst
    ee             10 小于150          21 morningSQL>
      

  3.   

    case when 从8i才开始支持。
      

  4.   

    结帖了,再次谢谢 Lastdrop(空杯) 和 lunar2000(春天花会开) 。没办法级别太低只能给一百分,真希望有机会可以请你们出来喝茶。我在深圳,你们在哪?