2016-03-17 148 views

回答

2

使用GREATEST函數返回從參數最大:

SELECT 
    greatest(
     (SELECT max(col) FROM table1), 
     (SELECT max(col) FROM table2), 
     ... 
    ) 
FROM dual 
2

你可以用UNION做到這一點:

SELECT max(cols) FROM(
    SELECT max(col) as cols from table1 
    UNION ALL 
    SELECT max(col) as cols from table2)