ELEMENTS_AT_POS()

All functions > ARRAY > ELEMENTS_AT_POS()

Returns the elements at multiple specified positions in an array.

Signatures

Returns: Array containing elements at the specified positions

ELEMENTS_AT_POS(array: ARRAY<T>, positions: ARRAY<BIGINT>) → ARRAY<T>
sql
ParameterTypeRequiredDescription
arrayARRAY<T>YesThe array to access
positionsARRAY<BIGINT>YesArray of 1-based positions to extract

Notes

  • Uses 1-based indexing for positions
  • Negative positions count from the end
  • Out of bounds positions return NULL for that element
  • Preserves the order of positions array

See also

Examples

FeatureQL
SELECT
    f1 := ELEMENTS_AT_POS(ARRAY[10, 20, 30, 40], ARRAY[4, 1]), -- Order follows positions array
    f2 := ELEMENTS_AT_POS(ARRAY[10, 20, 30], ARRAY[3, 1]) -- Multiple positions
;
Result
f1 ARRAYf2 ARRAY
[40, 10][30, 10]

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