A、B两个字段,哪个存在就取哪个,都存在取A,用什么函数

解决方案 »

  1.   


    with t as(
    select 1 A,2 B from dual
    union all
    select null,3 from dual
    union all
    select 4,null from dual
    )select nvl(A,B) from t  NVL(A,B)
    ----------
             1
             3
             4
      

  2.   

    2中简单方法  nvl(A,B)decode(A,null,B,A)
    麻烦点的 也可以通过case when判断
      

  3.   

    貌似也差不多case when A is null then B else A end