---
schema_version: "1"
id: b2f9ad83ed145c53cf1a91d3f692ac14467660982f2453e2eb1e0ac1fbc10dc5
title: ARRAY_GENERATE_SERIES (Numerical)
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/references/data-cloud-sql-reference/scalar-func/array-func/array-generate-series.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/array-generate-series.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 5bb1d686c821d385c6d55b5a7b93c89b05614c766430c8be22009134fc43e3f2
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# `ARRAY_GENERATE_SERIES` (Numerical)

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Creates an array of sequential values within a range.

## Syntax

```sql
array_generate_series(<start>, <stop>[, <step>])
```

## Arguments

### Required

- `<start>`: The starting value of the sequence.
- `<stop>`: The ending value of the sequence (inclusive).

### Optional

- `<step>`: The increment between values. The default is 1.

## Returns

Returns an array that contains sequential values from `start` to `stop`, incrementing by `step`.

## Considerations

- If you use a negative step, make sure `<start>` is greater than `<stop>`. If `<start>` is less than or equal to `<stop>`, the function returns an empty array.
- A negative step generates a descending sequence. A positive step generates an ascending sequence.
- This function is equivalent to the [generate_series (Numerical)](https://developer.salesforce.com/docs/data/data-cloud-query-guide/set-returning-func/generate-series.md) function but returns an array instead of a set of rows.
- Both the `start` and `stop` values are included in the generated series.
- The step size must be non-zero.
- The step size can also be negative. For negative step sizes, `start` must be greater than `stop`.
- For positive step sizes, if `start` is greater than `stop`, the function returns no rows.
- For negative step sizes, if `start` is less than `stop`, the function returns no rows.
- If any input is `null`, the function returns no rows.

## Examples

### Basic Usage

Create an array of integers from 1 to 5.

```sql
SELECT array_generate_series(1, 5) AS result;
```

Returns `[1, 2, 3, 4, 5]`.

### Generate Sequence with Step

Create an array of integers from 1 to 5 with step 2.

```sql
SELECT array_generate_series(1, 5, 2) AS result;
```

Returns `[1, 3, 5]`.

### Reverse Sequence with Negative Step

Create an array counting down from 5 to 1 in increments of 2.

```sql
SELECT array_generate_series(5, 1, -2) AS result;
```

Returns `[5, 3, 1]`.

### Decimal Reverse Sequence

Create a descending array with decimal values.

```sql
SELECT array_generate_series(3.7, 3.0, -0.3) AS result;
```

Returns `[3.7, 3.4, 3.1]`.

### Negative Step with Increasing Range (Empty Result)

When the step direction doesn't match the range direction, an empty array is returned.

```sql
SELECT array_generate_series(1, 5, -1) AS result;
```

Returns `[]`.

### Additional Examples

The examples in [generate_series examples](https://developer.salesforce.com/docs/data/data-cloud-query-guide/set-returning-func/generate-series.md#examples) apply to `array_generate_series`.

## Related Documentation

- [Array Data Type](https://developer.salesforce.com/docs/data/data-cloud-query-guide/datatype/array.md)
- [`ARRAY_GENERATE_SERIES` (Time-based)](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/array-generate-series-time.md) - the time-based version of this function
- [`generate_series` (Numerical)](https://developer.salesforce.com/docs/data/data-cloud-query-guide/set-returning-func/generate-series.md) - the set-returning version of this function
