select ( case when a is null and b is not null then b when a is not null and b is null then a when a is null and b is null then null else a - b end ) from tb
select decode(a,null,decode(b,null,null,b),decode(b,null,a,a-b)) from tb;
select A || decode(a,null,null,decode(b,null,null,'-')) || B from tb;或者select A || (case when a is not null and b is not null then '-' end) || B from tb;
decode(B,null,null,B), <- 这是 A=null 的判断
decode(B,null,A,A-B) <- 这是 A!=null 的判断
)
FROM tab_name
写晚了 :(原来 zmgowin(隐者(龙祖宗)) 也在写~ 并且比我快一步~ pfpf. :)