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.