numbers Table Function
-
numbers()– Returns an infinite table with a singlenumbercolumn (UInt64) that contains integers in ascending order, starting from 0. UseLIMIT(and optionallyOFFSET) to restrict the number of rows. -
numbers(N)– Returns a table with a singlenumbercolumn (UInt64) that contains integers from 0 toN - 1. -
numbers(N, M)– Returns a table with a singlenumbercolumn (UInt64) that containsMintegers fromNtoN + M - 1. -
numbers(N, M, S)– Returns a table with a singlenumbercolumn (UInt64) that contains values in[N, N + M)with stepS(aboutM / Srows, rounded up).Smust be>= 1.
This is similar to the system.numbers system table. It can be used for testing and generating successive values.
The following queries are equivalent:
The following queries are also equivalent:
The following queries are also equivalent:
Examples
The first 10 numbers.
Generate a sequence of dates from 2010-01-01 to 2010-12-31.
Find the first UInt64 >= 10^15 whose sipHash64(number) has 20 trailing zero bits.
Notes
- For performance reasons, if you know how many rows you need, prefer bounded forms (
numbers(N),numbers(N, M[, S])) over unboundednumbers()/system.numbers. - For parallel generation, use
numbers_mt(...)or thesystem.numbers_mttable. Note that results may be returned in any order.