GREATEST
Syntax
GREATEST(value1, ...)
Description
Returns the maximum value of the parameters. This function is the opposite of the LEAST() function.
At least two parameters are required (an error will be returned if only one parameter is provided). If any parameter is NULL, the function returns NULL.
If the parameters include both numeric and character values, the character values are implicitly converted to numeric values. An error is returned if the conversion is not possible.
Examples
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 (0.001 sec)
SELECT GREATEST(2);
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'greatest'