Skip to main content

ARRAY_GENERATE_RANGE

Categories: Semi-Structured Data

ARRAY_GENERATE_RANGE

Returns an array of integers in the specified range.

Syntax

ARRAY_GENERATE_RANGE(start int32, stop int32, step int32) → list

  • start: The first number in the range of numbers to return.
  • stop: The last number in the range. Note that this number is not included in the range of numbers returned.
  • step: The amount to increment or decrement each subsequent number in the array. May be a positive or negative number. Cannot be 0. Default value is 1.

Examples

ARRAY_GENERATE_RANGE example
SELECT ARRAY_GENERATE_RANGE(1, 5)
-- [1, 2, 3, 4]
ARRAY_GENERATE_RANGE example
SELECT ARRAY_GENERATE_RANGE(0, 16, 5)
-- [0, 5, 10, 15]
ARRAY_GENERATE_RANGE example
SELECT ARRAY_GENERATE_RANGE(0, -16, -5)
-- [0, -5, -10, -15]
ARRAY_GENERATE_RANGE example
SELECT ARRAY_GENERATE_RANGE(2, 2, 4)
-- []
ARRAY_GENERATE_RANGE example
SELECT ARRAY_GENERATE_RANGE(8, 2, 2)
-- []
ARRAY_GENERATE_RANGE example
SELECT ARRAY_GENERATE_RANGE(2, 8, -2)
-- []
ARRAY_GENERATE_RANGE example
SELECT ARRAY_GENERATE_RANGE(2, 2)
-- []