Handling Null in Greatest function in Oracle

后端 未结 9 1728
轮回少年
轮回少年 2021-02-14 05:36

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

9条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-14 06:06

    Something like

    SELECT CASE WHEN ColA is NULL and ColB is NULL then NULL
    WHEN coalesce(ColA, '01/01/1753')>coalesce(ColB, '01/01/1753') then ColA
    ELSE ColB END as Output
    

提交回复
热议问题