12345678910111213141516171819202122232425262728293031323334353637383940 |
- [discrete]
- [[esql-greatest]]
- === `GREATEST`
- *Syntax*
- [.text-center]
- image::esql/functions/signature/greatest.svg[Embedded,opts=inline]
- *Parameters*
- `first`::
- First of the columns to evaluate.
- `rest`::
- The rest of the columns to evaluate.
- *Description*
- Returns the maximum value from multiple columns. This is similar to <<esql-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`.
- *Supported types*
- include::types/greatest.asciidoc[]
- *Example*
- [source.merge.styled,esql]
- ----
- include::{esql-specs}/math.csv-spec[tag=greatest]
- ----
- [%header.monospaced.styled,format=dsv,separator=|]
- |===
- include::{esql-specs}/math.csv-spec[tag=greatest-result]
- |===
|