Available in versions: Dev (3.17) | Latest (3.16) | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10 | 3.9 | 3.8 | 3.7

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

# PERCENT_RANK

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The `PERCENT_RANK()` hypothetical set function calculates the percent rank of the hypothetical value, i.e. the relative rank from 0 to 1 (CUME_DIST produces values from 1/N to 1)

```SELECT
percent_rank(0) WITHIN GROUP (ORDER BY ID),
percent_rank(2) WITHIN GROUP (ORDER BY ID),
percent_rank(4) WITHIN GROUP (ORDER BY ID)
FROM BOOK```
```create.select(
percentRank(val(0)).withinGroupOrderBy(BOOK.ID),
percentRank(val(2)).withinGroupOrderBy(BOOK.ID),
percentRank(val(4)).withinGroupOrderBy(BOOK.ID))
.from(BOOK)```

Producing:

```+-----------------+-----------------+-----------------+
| percent_rank(0) | percent_rank(2) | percent_rank(4) |
+-----------------+-----------------+-----------------+
|             0.0 |            0.25 |            0.75 |
+-----------------+-----------------+-----------------+```

## Dialect support

This example using jOOQ:

`percentRank(val(0)).withinGroupOrderBy(BOOK.ID)`

Translates to the following dialect specific expressions:

```-- AURORA_POSTGRES, H2, ORACLE, POSTGRES, YUGABYTEDB
percent_rank(0) WITHIN GROUP (ORDER BY BOOK.ID)

-- ACCESS, ASE, AURORA_MYSQL, BIGQUERY, COCKROACHDB, DB2, DERBY, EXASOL, FIREBIRD, HANA, HSQLDB, INFORMIX, MARIADB, MEMSQL,
-- MYSQL, REDSHIFT, SNOWFLAKE, SQLDATAWAREHOUSE, SQLITE, SQLSERVER, SYBASE, TERADATA, VERTICA
/* UNSUPPORTED */
```

(These are currently generated with jOOQ 3.17, see #10141), or translate your own on our website