> ## 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":"css-variables","dark":"css-variables"}}
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

The `tournaments` table contains the following data:

<div className="query-window">
  ```
  SELECT name, totalprizedollars FROM tournaments ORDER BY totalprizedollars DESC LIMIT 5;
  ```

  | name <span>text null</span> | totalprizedollars <span>int null</span> |
  | :- | :- |
  | The Drifting Thunderdome | 24768 |
  | The Talladega Thrill | 24747 |
  | The Elite Speed Demons Cup | 24346 |
  | The Volcanic Venture Rally | 24323 |
  | The Drifting Wasteland | 24271 |

  <p><span>Rows: 5</span><span>Execution time: 6.00ms</span></p>
</div>

The following example finds the largest prize amount in the `tournaments` table:

<div className="query-window">
  ```
  SELECT MAX(totalprizedollars) AS maxprize FROM tournaments;
  ```

  | maxprize <span>int null</span> |
  | :- |
  | 24768 |

  <p><span>Rows: 1</span><span>Execution time: 5.86ms</span></p>
</div>

`MAX` also works on text columns, returning the lexicographically largest value. The following example finds the tournament name that comes last alphabetically:

<div className="query-window">
  ```
  SELECT MAX(name) AS maxtournament FROM tournaments;
  ```

  | maxtournament <span>text null</span> |
  | :- |
  | The Winter Wilderness Rally |

  <p><span>Rows: 1</span><span>Execution time: 5.94ms</span></p>
</div>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.