add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create function mygreatest(in a date, in b date) returns date
language sql
begin
if a is null then return b; end if;
if b is null then return a; end if;
if a > b then return a; end if;
return b;
end
with data (x, y) as (
select date '2021-07-01', date '2021-12-01' from sysibm.sysdummy1
union all select date '2021-07-01', null from sysibm.sysdummy1
union all select null, date '2021-12-01' from sysibm.sysdummy1
union all select null, null from sysibm.sysdummy1
)
select mygreatest(x, y) as g from data;
G
2021-12-01
2021-07-01
2021-12-01
null