Type to search.

ES|QL GREATEST function

Serverless

Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Serverless interfaces and procedures might differ from classic Elastic Stack deployments.

Stack

The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments.

This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

Returns the maximum value from multiple columns.

Embedded
Embedded
first
First of the columns to evaluate.
rest

The rest of the columns to evaluate.

Returns the maximum value from multiple columns. This is similar to MV_MAX except it is intended to run on multiple columns at once.

Note

When run on keyword or text fields, this returns the last string in alphabetical order. When run on boolean columns this will return true if any values are true.

first rest result
boolean boolean boolean
boolean boolean
date date date
date_nanos date_nanos date_nanos
double double double
integer integer integer
integer integer
ip ip ip
keyword keyword keyword
keyword keyword
long long long
long long
text text keyword
text keyword
version version version
ES|QL
ROW a = 10, b = 20
| EVAL g = GREATEST(a, b)
a:integer b:integer g:integer
10 20 20