Топ-100
 
CerebroSQL

NTH_VALUE

Database: MySQL

68747470733a2f2f7374796c65732e7265646469746d656469612e636f6d2f74355f32716d366b2f7374796c65

Topic

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

Example