# random

> 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: random
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/math-functions/random
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-functions/math-functions/random.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/math-functions/random.adoc
description: The `random()` function in Redpanda SQL generates a random number within a defined range.
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/math-functions/random.md -->

The `random()` function in Redpanda SQL generates a random number within a defined range. By default, the range is between 0 (inclusive) and 1 (exclusive), resulting in a value greater than or equal to 0 and less than 1.

## [](#syntax)Syntax

The syntax for generating a random integer or floating-point number using the `random()` function is:

```sql
RANDOM()
```

> 📝 **NOTE**
>
> There are no parameters or arguments for the `random()` function.

## [](#examples)Examples

### [](#generate-a-random-number)Generate a random number

The `random()` function generates a random number greater than or equal to zero but less than one by default. Use this syntax to retrieve a random number:

```sql
SELECT RANDOM();
```

The result is a random number greater than 0 and less than 1. However, it will never return the maximum value of 1.

```sql
+-----------------------+
| f                     |
+-----------------------+
| 0.9122627193276355    |
+-----------------------+
```

### [](#generate-a-random-decimal-number-within-a-range)Generate a random decimal number within a range

To generate a random decimal number between two values:

```sql
SELECT RANDOM()*(b-a)+a;
```

Where:

-   **“a”** represents the lower bound of the range.

-   **“b”** represents the upper bound of the range.


The return value will be a random floating-point number greater than or equal to a and less than b.

**Example**

To generate a random decimal number greater than or equal to 10 and less than 25:

```sql
SELECT RANDOM()*(25 - 10)+10;
```

This example shows how to retrieve a random number:

```sql
+-----------------------+
| f                     |
+-----------------------+
| 18.156098711616043    |
+-----------------------+
```

> ⚠️ **WARNING**
>
> It is important to note that the function will never return the maximum value of b.