Interviews4 answers
To Find nth Maximum Value from a Table in Sql.

Murali Reddy
Posted Aug 23, 2013, 10:48 PM EDT4 Answers
Select max(salary) from tb as max
Mukesh KumarPosted Sep 5, 2017, 12:11 AM EDT
SELECT * /*This is the outer query part */
FROM Employee Emp1
WHERE (N-1) = ( /* Subquery starts here */
SELECT COUNT(DISTINCT(Emp2.Salary))
FROM Employee Emp2
WHERE Emp2.Salary > Emp1.Salary)
And Another Answer can be:
DECLARE @N int
SET @N = 3 -- Change the value here to pick a different salary rank
SELECT Salary
FROM (
SELECT row_number() OVER (ORDER BY Salary DESC) as SalaryRank, Salary
FROM Salaries
) as SalaryCTE
WHERE SalaryRank = @N
Manju lata YadavPosted Jun 30, 2014, 11:26 PM EDT
select * from table1 t1 where (n-1)=(select Count(distinct(t2.salary)) from table1 t2 where t1.salary
srinivas thummalapalliPosted Oct 1, 2013, 5:56 AM EDT
select * from table1 t1 where 2=(select Count(*)+1 from table1 t2 where t1.salary>t2.salary)
Murali ReddyPosted Aug 23, 2013, 10:48 PM EDT

