This tutorial explains how to use the MySQL GREATEST function with syntax and examples.
The MySQL GREATEST function returns the greatest value in a list of expressions.
The syntax for the GREATEST function in MySQL is:
GREATEST( expr1, expr2, ... expr_n )
The expressions that are evaluated by the GREATEST function.
The GREATEST function can be used in the following versions of MySQL:
Let's look at some MySQL GREATEST function examples and explore how to use the GREATEST function in MySQL.
For example:
mysql> SELECT GREATEST(2, 5, 12, 3);
Output: 12
mysql> SELECT GREATEST('2', '5', '12', '3');
Output: '5'
mysql> SELECT GREATEST('AODBA.com', 'mysite.com', 'bing.com');
Output: 'mysite.com'
mysql> SELECT GREATEST('AODBA.com', 'mysite.com', null);
Output: NULL