Suppose that you are given the following simple database table called Employee that has 2 columns named Employee ID and Salary:
Employee
Employee ID S
This is awesome Query to find the nth Maximum: For example: -
You want to find salary 8th row Salary, Just Changed the indexed value to 8.
Suppose you have 100 rows with Salary. Now you want to find Max salary for 90th row. Just changed the Indexed Value to 90.
set @n:=0;
select * from (select *, (@n:=@n+1) as indexed from employee order by Salary desc)t where t.indexed = 1;