> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# generate_series (generateSeries)

> Returns a table with the single `generate_series` column (UInt64) that contains integers from start to stop inclusively.

Alias: `generateSeries`

<h2 id="syntax">
  Syntax
</h2>

Returns a table with the single 'generate\_series' column (`UInt64`) that contains integers from start to stop inclusively:

```sql theme={null}
generate_series(START, STOP)
```

Returns a table with the single 'generate\_series' column (`UInt64`) that contains integers from start to stop inclusively with spacing between values given by `STEP`:

```sql theme={null}
generate_series(START, STOP, STEP)
```

`STEP` can be negative, in which case the series is generated in descending order from `START` down to `STOP`. If `STEP` is negative and `START < STOP`, the result is empty.

<h2 id="examples">
  Examples
</h2>

The following queries return tables with the same content but different column names:

```sql theme={null}
SELECT * FROM numbers(10, 5);
```

```response theme={null}
┌─number─┐
│     10 │
│     11 │
│     12 │
│     13 │
│     14 │
└────────┘
```

```sql theme={null}
SELECT * FROM generate_series(10, 14);
```

```response theme={null}
┌─generate_series─┐
│              10 │
│              11 │
│              12 │
│              13 │
│              14 │
└─────────────────┘
```

And the following queries return tables with the same content but different column names (but the second option is more efficient):

```sql theme={null}
SELECT * FROM numbers(10, 11) WHERE number % 3 == (10 % 3);
```

```response theme={null}
┌─number─┐
│     10 │
│     13 │
│     16 │
│     19 │
└────────┘
```

```sql theme={null}
SELECT * FROM generate_series(10, 20, 3);
```

```response theme={null}
┌─generate_series─┐
│              10 │
│              13 │
│              16 │
│              19 │
└─────────────────┘
```

Generate a descending series:

```sql theme={null}
SELECT * FROM generate_series(9, 0, -1);
```

```response theme={null}
┌─generate_series─┐
│               9 │
│               8 │
│               7 │
│               6 │
│               5 │
│               4 │
│               3 │
│               2 │
│               1 │
│               0 │
└─────────────────┘
```
