# generate_series

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: generate_series
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: sql/sql-functions/other-functions/generate-series
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-functions/other-functions/generate-series.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/other-functions/generate-series.adoc
description: The `generate_series` function generates a set of values from start to stop with an optional step increment.
page-topic-type: reference
page-git-created-date: "2026-05-26"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/other-functions/generate-series.md -->

The `generate_series` function generates a set of values from a start value to a stop value with an optional step increment. Use it as a table function in the `FROM` clause.

## [](#syntax)Syntax

```sql
GENERATE_SERIES(start, stop)
GENERATE_SERIES(start, stop, step)
```

## [](#arguments)Arguments

-   `start`: The first value in the series. Type: `bigint`.

-   `stop`: The last value in the series (inclusive). Type: `bigint`.

-   `step`: Optional. The increment between values. Defaults to `1`. Use a negative value to generate a descending series. Type: `bigint`.


If `step` is positive and `start` is greater than `stop`, an empty set is returned. If `step` is negative and `start` is less than `stop`, an empty set is returned.

## [](#examples)Examples

### [](#generate-an-ascending-series)Generate an ascending series

```sql
SELECT * FROM GENERATE_SERIES(1, 5);
```

```sql
 generate_series
-----------------
               1
               2
               3
               4
               5
(5 rows)
```

### [](#generate-a-series-with-a-custom-step)Generate a series with a custom step

```sql
SELECT * FROM GENERATE_SERIES(0, 10, 2);
```

```sql
 generate_series
-----------------
               0
               2
               4
               6
               8
              10
(6 rows)
```

### [](#generate-a-descending-series)Generate a descending series

```sql
SELECT * FROM GENERATE_SERIES(5, 1, -1);
```

```sql
 generate_series
-----------------
               5
               4
               3
               2
               1
(5 rows)
```

### [](#filter-a-series-with-where)Filter a series with WHERE

```sql
SELECT * FROM GENERATE_SERIES(1, 10) WHERE generate_series % 2 = 0;
```

```sql
 generate_series
-----------------
               2
               4
               6
               8
              10
(5 rows)
```

### [](#aggregate-a-series)Aggregate a series

```sql
SELECT SUM(generate_series) FROM GENERATE_SERIES(1, 100);
```

```sql
 sum
------
 5050
(1 row)
```