I want to compare two dates from two columns and get the greatest and then compare against a date value.The two column can hold NULL values too.For example I want the below OUTP
Another version using a case expression to handle the null
values:
select cola, colb,
case when cola is null and colb is null then null
when cola is null then colb
when colb is null then cola
else greatest(cola, colb)
end as output
from ;
COLA COLB OUTPUT
---------- ---------- ----------
09/21/2013 01/02/2012 09/21/2013
01/03/2013 01/03/2013
01/03/2013 01/03/2013
- 热议问题