Re: nth_value out of more than n values returns null - Mailing list pgsql-general

From David G. Johnston
Subject Re: nth_value out of more than n values returns null
Date
Msg-id CAKFQuwYPU+j46pHakraap1d4jYzPVMx00o95NMe0WLuamkJp+g@mail.gmail.com
Whole thread Raw
In response to Re: nth_value out of more than n values returns null  (Guyren Howe <guyren@gmail.com>)
List pgsql-general
On Monday, November 4, 2024, Guyren Howe <guyren@gmail.com> wrote:
Wouldn’t it be offset 4_999_999?

Probably.  I tend to expect off-by-one for these kinds of things and test my way out.
 

I’d still like to understand why nth_value doesn’t work.

When you perform an order by in a window clause the frame you get by default ends at the current row.  Consider “count(*) over ()” versus “count(*) over (order by id)”.

You need to not use defaults for the window frame if this doesn’t suit you.

David J.

pgsql-general by date:

Previous
From: Guyren Howe
Date:
Subject: Re: nth_value out of more than n values returns null
Next
From: Tom Lane
Date:
Subject: Re: nth_value out of more than n values returns null