ELEMENT_AT_POS()

All functions > ARRAY > ELEMENT_AT_POS()

Returns the element at the specified position in an array.

Signatures

Returns: The element at the specified position

ELEMENT_AT_POS(array: ARRAY<T>, position: BIGINT) → T
sql
ParameterTypeRequiredDescription
arrayARRAY<T>YesThe array to access
positionBIGINTYes1-based position (negative values count from end)

Notes

  • Uses 1-based indexing (first element is at position 1)
  • Negative positions count from the end (-1 is last element)
  • Returns NULL if position is out of bounds
  • Returns NULL if array is NULL

See also

Examples

FeatureQL
SELECT
    f1 := ELEMENT_AT_POS(ARRAY[1, 2, 3], 2), -- 1-based index
    f2 := ELEMENT_AT_POS(ARRAY[1, 2, 3], -1), -- Negative index counts from end
    f3 := ELEMENT_AT_POS(ARRAY[1, 2, 3], 10) -- Out of bounds
;
Result
f1 BIGINTf2 BIGINTf3 BIGINT
23null

Last update at: 2026/05/26 17:22:09