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

# ARRAY_MAX

> Returns the largest non-NULL element of an array.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

Returns NULL for a NULL array, empty array or array containing only NULL elements. NULL elements are ignored.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
array_max(array)
```

## Arguments

Type notation used below:

* T is the array element type: BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, DECIMAL(p, s), STRING, BINARY, DATE, TIME, TIMESTAMP, ARRAY or STRUCT.

| Name | Type | Required | Description |
| - | - | - | - |
| array | ARRAY\<T> | Yes | An array with a comparable element type. Nested elements/fields must satisfy the same element-type restrictions. |

## Returns

* Type: T
* Possible values: The largest non-NULL element.
* NULL behavior: Returns NULL for a NULL array, empty array or array containing only NULL elements. NULL elements are ignored.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Yes |

## Usage notes

* NULL elements are ignored. An empty array or an array containing only NULL returns NULL. Floating-point ordering distinguishes positive and negative zero and different NaN values. STRING and BINARY values use lexicographic order; ARRAY and STRUCT values are compared by their elements or fields.
* INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.

## Examples

### Typical behavior

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT array_max(ARRAY[3, NULL, 1, 2]) AS "value";
```

| value |
| - |
| 3 |

### Compare date elements

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
WITH sample AS (
 SELECT id, CASE WHEN id = 0 THEN ARRAY(DATE '2024-01-01', DATE '2024-03-01')
   ELSE ARRAY(DATE '2024-04-01', DATE '2024-02-01') END AS dates FROM range(0, 2)
)
SELECT array_max(dates) AS latest_date FROM sample ORDER BY id;
```

| latest\_date |
| - |
| 2024-03-01 |
| 2024-04-01 |

## Limitations

* Elements must be comparable. MAP elements are not supported. The ordering of NaN and signed zero can differ from other SQL engines.
* MAP elements, including MAP values nested inside compared elements, are outside the supported element types.


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