NTH_VALUE (SQL) Contents Description Arguments Examples See Also A window function that assigns the value of the field column for row number n within the specified window frame to all rows in the window frame. Synopsis NTH_VALUE(field, n) Description NTH_VALUE assigns the value from the field column taken from row number n to all rows within the window frame. NTH_VALUE supports the ROWS clause. Arguments field A column that specifies which value to assign to all rows. n A number that denotes which row's field column value will be used. Examples The following example returns the second highest salary within each department: SELECT NTH_VALUE(Salary, 2) OVER (PARTITION BY Department ORDER BY Salary) FROM Company.Employee See Also Window functions overview FeedbackOpens in a new tab