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 with the following syntax:
650) this.width=650; "alt=" Description of Least.gif follows "src=" http://docs.oracle.com/cd/E11882_01/server.112/ E41084/img/least.gif "width=" "height="/>
650) this.width=650; "alt=" Description of Greatest.gif follows "src=" http://docs.oracle.com/cd/E11882_01/server.112/ E41084/img/greatest.gif "width=" 244 "height=" "/>"
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, based on the principle of numerical precedence.
Example:
Sql> Select least (' China ', ' England ', ' American ', ' Russia ') country from dual; Country------------------------American Sql> Select Greatest (' China ', ' England ', ' American ', ' Russia ') country from Dual Country------------------Russia
Sql> Select Least (1, ' England ', ' Russia ') country from dual;select least (1, ' England ', ' Russia ') country from dual *error at line 1:ora-01722:invalid number
An error occurred stating that when I specify a numeric type, subsequent expressions are converted to numeric values.
Sql> Select Least (1,3.14159,0.1415926) country from dual; Country----------. 1415926sql> Select Greatest (1,3.14159,0.1415926) country from dual; Country----------3.14159
Sql> Select least (' China ', ' England ', 2,1) country from dual;
COU
---
1
Here you can see that the subsequent values are converted to character types.
This article is from the "linuxoracle" blog, make sure to keep this source http://onlinekof2001.blog.51cto.com/3106724/1611811
Oracle comparison functions greatest and least use