NTH_VALUE(expr, N) [from_first_last] [null_treatment] over_clause

Returns the value of expr from the N-th row of the window frame. If
there is no such row, the return value is NULL.

N must be a literal positive integer.

from_first_last is part of the SQL standard, but the MySQL
implementation permits only FROM FIRST (which is also the default).
This means that calculations begin at the first row of the window. FROM
LAST is parsed, but produces an error. To obtain the same effect as
FROM LAST (begin calculations at the last row of the window), use ORDER
BY to sort in reverse order.

over_clause is as described in
https://dev.mysql.com/doc/refman/8.0/en/window-functions-usage.html.
null_treatment is as described in the section introduction.

For an example, see the FIRST_VALUE() function description.

URL: https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html

