Outdated Version

You are viewing an older version of this section. View current production version.

MAX

Aggregate function. Returns the highest value observed in all rows in an aggregation. “Highest” is determined by the collation rules of the data passed in.

Info

This aggregate function is not to be confused with GREATEST, which is a non-aggregate function returning the highest value in its list of arguments.

Syntax

MAX ( expression )

Arguments

  • expression: any expression. This may be a column name, the result of another function, or a math operation.

Return Type

The highest value, in the type of the input.

Examples

memsql> select max(person_id) from people;
+----------------+
| max(person_id) |
+----------------+
|           6336 |
+----------------+

memsql> select max(first_name) from people;
+-----------------+
| max(first_name) |
+-----------------+
| Zula            |
+-----------------+