If you’re getting an error that reads “window function nth_value requires an OVER clause” in PostgreSQL, it’s because you’re calling the nth_value() function without an OVER clause.
PostgreSQL requires that you include an OVER clause any time you call a built in nonaggregate window function such as nth_value().
To fix this issue, add an OVER clause to your window function.