2014-01-05 41 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 
相關問題