From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | oselemg(at)gmail(dot)com, pgsql-docs(at)lists(dot)postgresql(dot)org |
Subject: | Re: Typo on tutorial window page |
Date: | 2025-01-21 17:55:31 |
Message-ID: | CAKFQuwaYf8E5oB0t5VCAJZHeJ01XjWH0JKVhASruhSaBNiMOSA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-docs |
On Tue, Jan 21, 2025 at 10:39 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> PG Doc comments form <noreply(at)postgresql(dot)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.
>
> Hmm, I think the current text is correct, or at least more nearly
> correct than what you suggest.
> The ranks are separate within each partition (depname), and
> within a partition rows having the same salary get the
> same rank.
>
>
Sorry for the empty email - finger spasm hit send.
I was going to write basically that but something feels off to me. Maybe
something like this:
"As shown here, the rank function produces a numerical ranking within each
partition, using the order defined by the ORDER BY clause. Ranking assigns
the same rank to all rows that tie according to the order by criteria,
while still incrementing the rank counter. Thus there are gaps in the
serial numbering. These can be removed by instead using the dense_rank
window function. Ties can instead be given their own unique value by using
the row_number window function. In all these cases, as the window function
is effectively just counting rows, the function itself has no input
parameter."
If we don't want to get into that level of nuance in the tutorial I suggest
we use the row_number() window function instead of rank, and just say
because we count rows no parameter is needed.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2025-01-21 18:10:14 | Re: Typo on tutorial window page |
Previous Message | Олег Семенов | 2025-01-21 17:44:07 | Re: Typo on tutorial window page |