Handling Null in Greatest function in Oracle

后端 未结 9 1366
轮回少年
轮回少年 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:20

    Use Oracle CASE... WHEN structure in your select:

    SELECT COLA, COLB, CASE
      WHEN (COLA >= COLB OR COLB IS NULL)
        THEN COLA
      ELSE COLB
      END
      AS OUTPUT
    FROM ...
    

提交回复
热议问题