THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL GREATEST() Function

❮ MySQL Functions

Example

Return the greatest value in a list of expressions:

SELECT GREATEST(3, 12, 34, 8, 25);
Try it Yourself »

Definition and Usage

The GREATEST() function returns the greatest value in a list of expressions.

Note: See also the LEAST() function.

Syntax

GREATEST(expr1, expr2, expr3, ...)

Parameter Values

Parameter Description
expr1, expr2, expr3, ... Required. The expression list to be evaluated

Technical Details

Works in: MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

More Examples

Example

Return the greatest value in a list of expressions:

SELECT GREATEST("w3Schools.com", "microsoft.com", "apple.com");
Try it Yourself »

❮ MySQL Functions