Re: nth_value out of more than n values returns null

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Guyren Howe <guyren(at)gmail(dot)com>
Cc: Erik Wienhold <ewie(at)ewie(dot)name>, PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: nth_value out of more than n values returns null
Date: 2024-11-04 23:53:30
Message-ID: CAKFQuwYPU+j46pHakraap1d4jYzPVMx00o95NMe0WLuamkJp+g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Monday, November 4, 2024, Guyren Howe <guyren(at)gmail(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2024-11-05 00:49:52 Re: nth_value out of more than n values returns null
Previous Message Guyren Howe 2024-11-04 23:46:08 Re: nth_value out of more than n values returns null