> For the complete documentation index, see [llms.txt](https://docs.scanner.dev/scanner/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scanner.dev/scanner/using-scanner-complete-feature-reference/querying-and-analysis/aggregation-functions/max.md).

# max()

`max(col [, ...cols])` returns the maximum value of the provided column(s) in the input datastream. If multiple columns are provided, their values are lexically ordered as a tuple.

### Note

`max(a, b)` is not the same as `max(a), max(b)`. To get the maximum values of multiple columns, run a `stats` query, e.g. `stats max(a), max(b)`. See [stats()](/scanner/using-scanner-complete-feature-reference/querying-and-analysis/aggregation-functions/stats.md) for more information.

### Ordering

Ordering is alphabetical/lexical for strings, and numeric for numbers. If multiple columns are supplied, the ordering of the whole is evaluated lexically as a tuple, e.g. we compare the first values, then, if they're equal, we compare the second values, then, if they're equal, we compare the third values, etc.

If a field contains data of multiple types, numeric values are considered greater than text values, and text values are considered greater than `null` values. E.g.:

* `[1] < [2]`
* `["a"] < ["aa"]`
* `["a"] < [1]`
* `[1, 2] < [2, 1]`
* `[1, 1] < [1, 2]`
* `["ab", "a"] > ["a", "ca"]`
* `["ab", 1] > ["a", 2]`
* `[1, null] < [1, 2]`

## Returns

A table with one row and one column for each `col` provided, called `@q.max[i]`, where `i` is the index of `col` in the arguments. If only one `col` was provided, the column is called `@q.max`.

## Example

Return the maximum elapsed time for a request in the **checkout\_api** service.

```python
@scnr.source_type: "kubernetes"
and kubernetes.container_name: "checkout_api"
| max(log.elapsed_ms)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.scanner.dev/scanner/using-scanner-complete-feature-reference/querying-and-analysis/aggregation-functions/max.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
