"David G. Johnston" <david.g.johns...@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


Reply via email to