Returns a table containing a list of count integers. The first number is start, and the following numbers
are produced by successively incrementing by step (1 by default). This function is used in the
clause of a
SELECT statement and can participate in
JOINs as if it were a table.
RANGE(start, count, [step])
- start (integer expression)
The first number.
- count (integer expression)
Specifies how many rows to return in the table.
- step (integer expression, optional)
Specifies the increment used to produce each new value in the list. By default, a step of 1 is used, which generates consecutive integers.
A table with a single column named
SELECT number FROM RANGE(1, 10);
Returns a 10-row table containing the numbers 1 through 10 in ascending order.
SELECT number FROM RANGE(10, 10, -1);
Returns a 10-row table containing the numbers 10 through 1 in descending order.
SELECT number FROM RANGE(1, 10) ORDER BY number DESC;
Another way to generate a 10-row table containing the numbers 10 through 1 in descending order.