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
I tried this..found after googling
WITH ABC AS ( SELECT NULL AS col1 , NULL AS col2 FROM dual UNION
SELECT NULL , DATE'2013-08-12' FROM dual UNION
SELECT DATE'2013-08-12' , NULL FROM dual UNION
SELECT DATE'2013-08-12', DATE'2013-09-12' FROM dual)
SELECT col1, col2 , substr(greatest('x'||col1,'x'||col2),2)
FROM ABC;