The Oracle comparison functions GREATEST and LEAST use
Http://docs.oracle.com/cd/E11882_01/server.112/e41084/functions069.htm#i77473
Http://docs.oracle.com/cd/E11882_01/server.112/e41084/functions087.htm#i77700
These two functions are a pair of opposite functions, and the syntax is:
They all determine the data type of the return value by the character type of the first expr. If the first expression is numeric, the function implicitly converts the subsequent expression to a numeric type according to the principle of numerical priority.
Example:
SQL > select least ('china','england','american','russia') country from dual;COUNTRY----american SQL > select greatest (' china','england','american','russia') country from dual;COUNTRY-russiaSQL > select least Select least (1) country from dual * ERROR at line 1:ORA-01722: invalid number
An error occurs, indicating that when I specify a numeric type, subsequent expressions are converted to numeric type
SQL > select least (1MIT 3.14159JEL 0.1415926) country from dual; COUNTRY- .1415926SQL > select greatest (1Min 3.14159JEL 0.1415926) country from dual; COUNTRY- 3.14159
SQL > select least ('china','england',2,1) country from dual
COU
-
one
Here you can see that the subsequent values here have been converted to character types.