create table TestTable(
ID number(1),
Num1 number(2),
Num2 number(2),
Num3 number(2),
Num4 number(2));
insert into TestTable values(1,null,null,null, 1);
insert into TestTable values(2,null,null, 2,null);
insert into TestTable values(3,null, 3,null,null);
insert into TestTable values(4, 4,null,null,null);
insert into TestTable values(5, 5, 6, 7, 8);
insert into TestTable values(6, 9, 10, 11,null);
insert into TestTable values(7,null,null, 12, 13);
insert into TestTable values(8, 14, 15,null, 17);
insert into TestTable values(9,null, 18, 19,null);
commit;
select ID,Num1,Num2,Num3,Num4,
greatest(coalesce(Num1,Num2,Num3,Num4),
coalesce(Num2,Num1,Num3,Num4),
coalesce(Num3,Num1,Num2,Num4),
coalesce(Num4,Num1,Num2,Num3)) as maxNum
from TestTable
order by ID;