2014-01-05 42 views

回答

1

试试这个:

declare 
maxNumCol nubmer; 
maxNum nubmer := 0; 
begin 
for aCol in (select column_name from user_tab_cols where table_name = 'MY_TABLE' and column_type = 'NUMBER') loop 
    execute immediate 'select max('||aCol.column_name||') from MY_TABLE' into maxNumCol; 
    maxNum := greatest(maxNum, maxNumCol); 
end loop; 
dbms_output.put_line(maxNum); 
end; 

也许你也该可以使用的,但我不知道:

select greatest(max(col_a), max(col_b), max(col_c)) from my_table 
+0

谢谢你...我会尝试 – user3162380

0

无程序脚本

select MAX(num) 
from 
(
select colA as num 
from test 
union 
select colB 
from test 
union 
Select colC 
from test 
union 
. 
. 

) x 
相关问题