1.使用oracle内置的greatest()和least()函数,具体示例如下:
select 5 as col1,6 as col2,9 as col3,1 as col4 from dual;
--------------------------------------
col1 | col2 |col3 |col4
5 6 9 1
select greatest(5,6,9,1) as maxcol, least(5,6,9,1) as mincol from dual;
--------------------------------------
maxcol | mincol
9 1