totn MariaDB Functions

MariaDB: GREATEST Function

This MariaDB tutorial explains how to use the MariaDB GREATEST function with syntax and examples.

Description

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

Syntax

The syntax for the GREATEST function in MariaDB is:

GREATEST( expr1, expr2, ... expr_n )

Parameters or Arguments

expr1, expr2, ... expr_n
The expressions that are evaluated by the GREATEST function.

Note

  • If the list of expressions are numeric values, the GREATEST function will return the largest numeric value.
  • If the list of expressions are string values, the GREATEST function will return the largest string value.

Applies To

The GREATEST function can be used in the following versions of MariaDB:

  • MariaDB 10

Example

Let's look at some MariaDB GREATEST function examples and explore how to use the GREATEST function in MariaDB.

For example:

SELECT GREATEST(8, 9, 10);
Result: 10

SELECT GREATEST('8', '9', '10');
Result: '9'

SELECT GREATEST('TechOnTheNet.com', 'CheckYourMath.com', 'BigActivities.com');
Result: 'TechOnTheNet.com'

SELECT GREATEST('TechOnTheNet.com', 'CheckYourMath.com', NULL);
Result: NULL