> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

> Reference material for MAX

# MAX

Returns the maximum value in its argument. NULL values are ignored. If all inputs are NULL, `MAX` returns NULL.

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
MAX(<expression>) [FILTER ([WHERE] <condition>)]
```

## Parameters

| Parameter      | Description                                                       | Supported input types |
| :------------- | :---------------------------------------------------------------- | :-------------------- |
| `<expression>` | The expression whose maximum to determine                         | Any type              |
| `<condition>`  | An optional boolean expression to filter rows used in aggregation | `BOOL`                |

## Return Types

Same as input type

## Examples

**Example**

This code example uses the following `tournaments` table:

| name                          | totalprizedollars |
| :---------------------------- | :---------------- |
| The Drifting Thunderdome      | 24,768            |
| The Lost Track Showdown       | 5,336             |
| The Acceleration Championship | 19,274            |
| The Winter Wilderness Rally   | 21,560            |
| The Circuit Championship      | 9,739             |

When used on the `totalprizedollars` column, `MAX` will return the highest value, as follows:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT
	MAX(totalprizedollars) as maxprize
FROM
	tournaments;
```

**Returns**

`24,768`

**Example**

`MAX` can also work on text or array columns, in which case it returns the lexicographically largest value. In this example, the function assesses the `name` column in the `tournaments` table.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT
	MAX(name) as maxtournament
FROM
	tournaments;
```

**Returns**

`The Winter Wilderness Rally`
