> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CUME_DIST

> Returns the fraction of rows in the group that come before or tie with the current row in the specified order.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Window function</span></div>

Returns a non-NULL fraction for every input row.

## Syntax

A window function keeps each input row and adds a result for that row. `PARTITION BY` groups rows with matching values; without it, all input rows form one group.

### Window

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
cume_dist() OVER ([PARTITION BY key] ORDER BY ordering_key)
```

## Arguments

Takes no arguments.

## Returns

* Type: DOUBLE
* Possible values: Greater than 0 and at most 1 for groups containing at least one row.
* NULL behavior: Returns a non-NULL fraction for every input row.
* Empty input: An empty input produces no rows.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | Yes |
| Supports window frames | No |
| Exact result | Partial (DOUBLE division introduces floating-point rounding.) |

## Usage notes

* Peers with equal ORDER BY values share the cumulative fraction; the final peer group receives 1.
* Explicit window-frame clauses are not supported for this function.

## Examples

### Peer groups

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
WITH t("value") AS (VALUES (1), (1), (2), (2)) SELECT "value", cume_dist() OVER (ORDER BY "value") AS result FROM t ORDER BY "value";
```

| value | result |
| - | - |
| 1 | 0.5 |
| 1 | 0.5 |
| 2 | 1.0 |
| 2 | 1.0 |

### Restart the calculation in each group

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
WITH sample(grp, row_id, v) AS (VALUES ('a', 1, 10), ('a', 2, 10), ('a', 3, 20), ('b', 4, 5))
SELECT grp, row_id, v, round(cume_dist() OVER (PARTITION BY grp ORDER BY v NULLS LAST), 6) AS result
FROM sample ORDER BY grp, row_id;
```

| grp | row\_id | v | result |
| - | - | - | - |
| a | 1 | 10 | 0.666667 |
| a | 2 | 10 | 0.666667 |
| a | 3 | 20 | 1 |
| b | 4 | 5 | 1 |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.