Declaration
GREATEST(value1, ...)
Description
Return the maximum value of the parameters, which is the opposite of the LEAST() function.
The function requires at least two parameters. If only one parameter is provided, an error is returned. If any parameter is NULL, the function returns NULL.
When both numeric and character values are present in a parameter, the character values are implicitly converted to numeric types for processing. If a conversion is not possible, an error is reported.
Examples
obclient> SELECT GREATEST(2,1), GREATEST('2',1,0), GREATEST('a','b','c'), GREATEST('a', NULL, 'c'), GREATEST('2014-05-15','2014-06-01')\G
*************************** 1. row ***************************
GREATEST(2,1): 2
GREATEST('2',1,0): 2
GREATEST('a','b','c'): c
GREATEST('a', NULL, 'c'): NULL
GREATEST('2014-05-15','2014-06-01'): 2014-06-01
1 row in set
obclient> SELECT GREATEST(2);
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'greatest'