Returns the nth value in the window frame.
Syntax
NTH_VALUE(expr, n) OVER (w)Example
Enter values below to update the example in real time.
department_id→employee_id→salary→second_highest→employees→SELECT department_id, employee_id, salary,
NTH_VALUE(salary, 2) OVER (
PARTITION BY department_id ORDER BY salary DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS second_highest
FROM employees;