> ## 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_POSITION

> Returns the first 1-based position of an element in an array.

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

Returns NULL for a NULL array or search element.

## Syntax

### Scalar

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

## 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 or ARRAY.

| Name | Type | Required | Description |
| - | - | - | - |
| array | ARRAY\<T> | Yes | The array to search. Nested elements/fields must satisfy the same element-type restrictions. |
| element | T | Yes | The element to find. Nested elements/fields must satisfy the same element-type restrictions. |

## Returns

* Type: unsigned 64-bit integer; query tools may report INTEGER
* Possible values: A 1-based position, or zero when not found.
* NULL behavior: Returns NULL for a NULL array or search element.

## Properties

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

## Usage notes

* 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_position(ARRAY[1, 2, 2], 2) AS first, array_position(ARRAY[1, 2], 3) AS absent;
```

| first | absent |
| - | - |
| 2 | 0 |

### Find a string and a missing value

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT array_position(ARRAY('red', 'blue'), 'blue') AS found, array_position(ARRAY('red', 'blue'), 'green') AS missing;
```

| found | missing |
| - | - |
| 2 | 0 |

## Limitations

* The position is returned as an unsigned 64-bit integer, even when query tools report INTEGER.
* Scalar elements and nested arrays are supported. MAP and STRUCT elements are not supported.


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