---
title: cume_dist analytic window function
description: Learn the syntax of the cume\_dist window function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/cume_dist
---

# `cume_dist` analytic window function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Returns the position of a value relative to all values in the partition.

## Syntax

```
cume_dist() over_clause
```

## Arguments

* [over\_clause](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-window-functions.md): The clause describing the windowing. See: [Window functions](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-window-functions.md).

## Returns

A `DOUBLE`.

The OVER clause of the window function must include an [ORDER BY clause](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-qry-select-orderby.md).
If the order is not unique the duplicates share the same relative later position.
`cume_dist() over(order by expr)` is similar, but not identical to `rank() over(order by position) / count(*)` since [`rank` ranking window function](https://docs.databricks.com/aws/en/sql/language-manual/functions/rank.md) produces the earliest absolute order.

## Examples

```sql
> SELECT a, b, cume_dist() OVER (PARTITION BY a ORDER BY b)
    FROM VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1) tab(a, b);
 A1 1   0.6666666666666666
 A1 1   0.6666666666666666
 A1 2   1.0
 A2 3   1.0
```

## Related functions

* [`rank` ranking window function](https://docs.databricks.com/aws/en/sql/language-manual/functions/rank.md)
* [`dense_rank` ranking window function](https://docs.databricks.com/aws/en/sql/language-manual/functions/dense_rank.md)
* [`row_number` ranking window function](https://docs.databricks.com/aws/en/sql/language-manual/functions/row_number.md)
* [Window functions](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-window-functions.md)
