ARRAY_GENERATE_RANGE

functionsupportedCore SQL functions

docs.snowflake.com ↗

Semi-structured and structured data functions

Returns an ARRAY of integer values within a specified range (e.g. [2, 3, 4]).

Syntax

supportedpartialnot supportednot scored

ARRAY_GENERATE_RANGE( <start> , <stop> [ , <step> ] )

Parameters

NameRequiredDescription
startrequiredThe first number in the range of numbers to return. You must specify an expression that evaluates to an INTEGER value.
stoprequiredThe last number in the range. Note that this number is not included in the range of numbers returned. For example, ARRAY_GENERATE_RANGE(1, 5) returns [1, 2, 3, 4] (which does not include 5). You must specify an expression that evaluates to an INTEGER value.
stepoptionalThe amount to increment or decrement each subsequent number in the array. For example: ARRAY_GENERATE_RANGE(0, 16, 5) returns [0, 5, 10, 15] ARRAY_GENERATE_RANGE(0, -16, -5) returns [0, -5, -10, -15] You can specify a positive or negative number. You cannot specify 0. The default value is 1.

Returns

An ARRAY of integers in the specified range. If any of the arguments is NULL, the function returns NULL.

Usage notes