↑↓ select ↵ open ⌫ change scope Open full search

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

Functions / Aggregate Functions

percent_rank

Read the PG 18 manual

Computes the relative rank of the hypothetical row, that is (rank - 1) / (total rows - 1).

Reading PG 18current·documented in 19 of 27 versions, 8.4 to 20

Signatures & examples

percent_rank ( args ) WITHIN GROUP ( ORDER BY sorted_args ) → 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
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.
Version history 3
  1. 12 → 13 changed
  2. 9.3 → 9.4 changed
  3. 8.3 → 8.4 added

Definition snapshot: b7bd9cda · English manual source