日期:2014-05-17  浏览次数:20896 次

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

------解决方案--------------------
SQL code

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中简单方法
SQL code

nvl(A,B)

decode(A,null,B,A)