Lists & arrays Scalar Table

range()

Creates a list of values between start and stop - the stop parameter is exclusive.

Reference: Haybarn WASM 2.0.0-rc12

Arguments & returns

10 overloads

range(stop)

Scalar
Overload link stop Returns
#01 BIGINT BIGINT[]

range(start, stop)

Scalar
Overload link startstop Returns
#02 BIGINTBIGINT BIGINT[]

range(start, stop, step)

Scalar
Overload link startstopstep Returns
#03 BIGINTBIGINTBIGINT BIGINT[]
#04 TIMESTAMP WITH TIME ZONETIMESTAMP WITH TIME ZONEINTERVAL TIMESTAMP WITH TIME ZONE[]
#05 TIMESTAMPTIMESTAMPINTERVAL TIMESTAMP[]

range(stop)

Table
Overload link stop Returns
#06 BIGINT TABLE

range(start, stop)

Table
Overload link startstop Returns
#07 BIGINTBIGINT TABLE

range(start, stop, step)

Table
Overload link startstopstep Returns
#08 BIGINTBIGINTBIGINT TABLE
#09 TIMESTAMP WITH TIME ZONETIMESTAMP WITH TIME ZONEINTERVAL TABLE
#10 TIMESTAMPTIMESTAMPINTERVAL TABLE

Generate a sequence with an exclusive stop

Generate numeric sequences as a list or as rows. The stop value is excluded, which makes range useful for bounded iteration.

With a positive step, a start equal to the stop produces no values.

Generate a sequence with an exclusive stop
SQL
Haybarn WASM 2.0.0-rc12 · In your browser

Guide example · Run to view results.

Expected result
values_listempty_list
[1, 2, 3][]

Watch for: Use generate_series() when the stop value should be included. Put range() in FROM to generate rows instead of a list.

Example

range example
SQL
Haybarn WASM 2.0.0-rc12 · In your browser

Engine example · Run to view results.

In a query

Make a small dataset from nothing.

A table function produces rows you can query. range starts at zero and stops before the upper bound.

Make a small dataset from nothing.
SQL
Haybarn WASM 2.0.0-rc12 · In your browser

Guide recipe · Run to view results.

In other engines

Snowflakearray_generate_range()

ARRAY_GENERATE_RANGE(0, 3)
In Haybarn
RANGE(0, 3)

SQLGlot example ↗