↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / Functions

percent_rank

Computes the relative rank of the hypothetical row, that is (rank - 1) / (total rows - 1). The value thus ranges from 0 to 1 inclusive.

English manual coverage begins with PostgreSQL 7.1. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

group
aggregate
group label
聚合函数
lang
en
layout
table-new
pages
functions-aggregate.html, functions-window.html
prose only
false

Definition PG 18

Computes the relative rank of the hypothetical row, that is (rank - 1) / (total rows - 1). The value thus ranges from 0 to 1 inclusive.

Signatures and overloads

percent_rank ( args ) WITHIN GROUP ( ORDER BY sorted_args ) → double precision → double precision
Computes the relative rank of the hypothetical row, that is (rank - 1) / (total rows - 1). The value thus ranges from 0 to 1 inclusive.
percent_rank () → double precision → double precision
Returns the relative rank of the current row, that is (rank - 1) / (total partition rows - 1). The value thus ranges from 0 to 1 inclusive.

Compare versions

Complete source facts

documentation revision

{"inputs":[{"file":"functions-aggregate.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"31d3dcd36ef353484b4b3535f9f0d1cc239c3910146257fe5178f99b90b501e2","version":"18.7"},{"file":"functions-window.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"439ef40b6ad39f35f5b4543f2cf5766744ce6b7a8c5c75c0b4c0a7c27cbb7574","version":"18.7"},{"file":"functions-aggregate.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"0bf7506d27b71666fc74840a21a8f77c8a92735174f1d05033865961722e457c","version":"18.7"},{"file":"functions-window.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"cf993ee76845c3f6c445b1045d674ce10d648125a8444e263a13384ed0e268f0","version":"18.7"}],"release":"18.7","runtime_remeasured":false,"source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552"}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · wiki-repair-20261023:5c084c8302f4f9f8c79fd7474b04c5a763d7e68078385eed4d99cbc0030a2fca

Text language: en · wiki-repair-20261023:5c084c8302f4f9f8c79fd7474b04c5a763d7e68078385eed4d99cbc0030a2fca