GREATEST(x1,x2[,...])

Description: Returns the greatest of a list of at least two values.

The rules for comparison are as follows:

  • If all arguments are integers or function is used in an integer context, arguments are compared as integers.

  • If all arguments are floating-point or function is used in a floating-point context, arguments are compared as floating-point values.

  • If any argument is a case-sensitive (binary) string, the arguments are compared as strings in a case-sensitive way; otherwise, the arguments are compared as strings in a way that is not case-sensitive.

Examples:

  • GREATEST(32,1) returns 32.

  • GREATEST(32,1)+0.00 returns 32.00.

  • GREATEST(-32,-1) returns -1.

  • GREATEST(BINARY "x","Y") returns x.

  • GREATEST("x","Y") returns Y.

See also: LEAST() ...

Get Sams Teach Yourself MySQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.