Interviews - C# Corner

Murali Reddy
To Find nth Maximum Value from a Table in Sql.
By Murali Reddy in SQL Server onAug 24 2013
  • Mukesh Kumar
    Sep, 2017 5

    Select max(salary) from tb as max

    • 0
  • Manju lata Yadav
    Jul, 2014 1

    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 rankSELECT Salary FROM (SELECT row_number() OVER (ORDER BY Salary DESC) as SalaryRank, SalaryFROM Salaries ) as SalaryCTE WHERE SalaryRank = @N

    • 0
  • srinivas thummalapalli
    Oct, 2013 1

    select * from table1 t1 where (n-1)=(select Count(distinct(t2.salary)) from table1 t2 where t1.salary

    • 0
  • Murali Reddy
    Aug, 2013 24

    select * from table1 t1 where 2=(select Count(*)+1 from table1 t2 where t1.salary>t2.salary)



    • 0

Most Popular Companies

Most Popular Job Functions

MOST LIKED QUESTIONS