SELECT NTH_VALUE(id, 5000000) OVER (ORDER BY created_at, id ASC) FROM table in a table where SELECT COUNT(*) returns a value a few thousand over 5 million, where id is the primary key, returns null. The inclusion of the primary key should make the order by a total order. So there should be a 5 millionth row. How can this happen?