Coalesce is handy. The definition of it is "The COALESCE() function returns the first non-null value in a list.". However, it doesn't seem to work for certain scenarios... Why don't these two examples work?
In the first statement above, it's dividing by zero which is invalid, but I would have thought it would then give me the zero. In the second one, I would have thought the invalid date of Feb 31 would have caused it to give me the second date. Both of the above statements give me null instead of my non-null alternative.
I thought I even saw an IBM example of coalesce being used on dates.
Code:
select coalesce(1/0,0) from SYSIBM.SYSDUMMY1
select COALESCE(DATE('2020-02-31'),'0001-01-01') from SYSIBM.SYSDUMMY1
I thought I even saw an IBM example of coalesce being used on dates.



Comment