On Tue, Jan 21, 2025 at 10:39 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
PG Doc comments form <noreply@postgresql.org> writes: > EXPECTED: > As shown here, the rank function produces a numerical rank for each distinct > PARTITION BY value in the current row's partition, using the order defined > by the ORDER BY clause. rank needs no explicit parameter, because its > behavior is entirely determined by the OVER clause.
> ACTUAL: > As shown here, the rank function produces a numerical rank for each distinct > ORDER BY value in the current row's partition, using the order defined by > the ORDER BY clause. rank needs no explicit parameter, because its behavior > is entirely determined by the OVER clause.
Hmm, I think the current text is correct, or at least more nearly correct than what you suggest.
Look at the example:
<programlisting> SELECT depname, empno, salary, rank() OVER (PARTITION BY depname ORDER BY salary DESC) FROM empsalary; </programlisting>