agora inbox for pgsql-docs@postgresql.org
help / color / mirror / Atom feedFrom: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: oselemg@gmail.com
Cc: pgsql-docs@lists.postgresql.org
Subject: Re: Typo on tutorial window page
Date: Tue, 21 Jan 2025 13:10:14 -0500
Message-ID: <3363256.1737483014@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwaYf8E5oB0t5VCAJZHeJ01XjWH0JKVhASruhSaBNiMOSA@mail.gmail.com>
References: <173737973383.1070.1832752929070067441@wrigleys.postgresql.org>
<3359764.1737481165@sss.pgh.pa.us>
<CAKFQuwaYf8E5oB0t5VCAJZHeJ01XjWH0JKVhASruhSaBNiMOSA@mail.gmail.com>
"David G. Johnston" <david.g.johnston@gmail.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
view thread (6+ messages)
Message-ID: <3363256.1737483014@sss.pgh.pa.us>
Permalink: ../3363256.1737483014@sss.pgh.pa.us/
Also on: postgresql.org/message-id/3363256.1737483014@sss.pgh.pa.us
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, oselemg@gmail.com, pgsql-docs@lists.postgresql.org
Subject: Re: Typo on tutorial window page
In-Reply-To: <3363256.1737483014@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox