Is there a nicer way of comparing if two values are equal if they can be nulls other than the following?
a = b or (a is null and b is null)
Is there a nicer way of comparing if two values are equal if they can be nulls other than the following?
a = b or (a is null and b is null)
You can:
a=b or coalesce(a,b) is null
You could also use nvl
, but that is a legacy function and coalesce
is quicker, since it stops at the first non-null
You can use DECODE(A,B,1) = 1
DECODE is irregular in its treatment of NULLs.
However I think the intention is unclear and prefer vol7ron's answer. Clarity over minimising typing !
You can wrap it with nvl and set it to some value not expected in your set:
NVL(a,0) = NVL(b,0)