Re: Typo on tutorial window page

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
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 18:10:14
Message-ID: 3363256.1737483014@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> 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.

Yeah, I was wondering if it'd be worth bringing up dense_rank,
but decided "probably not". I like your idea of switching the
example to use row_number to simplify things. What would the
text be then? Perhaps

As shown here, the <function>row_number</function> function
assigns sequential numbers to the rows within each partition,
in the order defined by the <literal>ORDER BY</literal> clause
(with tied rows numbered in an unspecified order).
<function>row_number</function> needs no explicit parameter,
because its behavior
is entirely determined by the <literal>OVER</literal> clause.

regards, tom lane

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message jian he 2025-01-22 06:28:54 Re: substring synopsis section, third argument is optional doc didn't show that
Previous Message David G. Johnston 2025-01-21 17:55:31 Re: Typo on tutorial window page