How to fix 22016: invalid_argument_for_nth_value_function in PostgreSQL | DevErrors