📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

GREATEST



Returns the maximum value from a set of values. If any value in the set is NULL, the function returns NULL.

See also: GREATEST_IGNORE_NULLS

Syntax

GREATEST(<value1>, <value2> ...)

Examples

SELECT GREATEST(5, 9, 4), GREATEST(5, 9, null);
┌──────────────────────────────────────────┐ │ greatest(5, 9, 4) │ greatest(5, 9, NULL) │ ├───────────────────┼──────────────────────┤ │ 9NULL │ └──────────────────────────────────────────┘

Was this page helpful?