Syntax
GREATEST(value1, ...)
Purpose
You can call this function to return the greatest one of the specified arguments. It is opposite to the LEAST() function.
This function must have at least two arguments. If you specify only one argument, an error is returned. If any argument is NULL, the function returns NULL.
If the arguments include both a numeric value and a character, the character is implicitly converted into a numeric value. An error is returned if the conversion fails.
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 (0.00 sec)
obclient> SELECT GREATEST(2);
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'greatest'