Sanjay Kesarwani
Find the 5th highest salary of employee.
By Sanjay Kesarwani in SQL Server on Jul 17 2016
  • Code Alone
    Sep, 2018 5

    WITH RESULT AS (SELECT SALARY,DENSE_RANK() OVER (ORDER BY SALARY DESC) AS DENSERANKFROM EMPLOYEES ) SELECT TOP 1 SALARY FROM RESULT WHERE DENSERANK = 5Never use ROW_NUMBER(). Always use DENSE_RANK()

    • 3
  • Code Alone
    Sep, 2018 5

    SELECT TOP 1 SALARY FROM (SELECT DISTINCT TOP 5 SALARY FROM EMPLOYEES ORDER BY SALARY DESC ) RESULT ORDER BY SALARY

    • 2
  • Rakesh Jogani
    Jul, 2017 16

    WITH Salaries AS (SELECT SalaryAmount, ROW_NUMBER() OVER(ORDER BY SalaryAmount DESC) AS 'RowNum'FROM dbo.SalaryTable ) SELECTSalaryAmount FROMSalaries WHERERowNum = 5

    • 2
  • Shashikant Patil
    Feb, 2017 27

    1) C# doesn't support Multiple inheritance ( means deriving a class from more than one class)... If your application supposed to have more than one class features at a time, For ex : we can inherit one class and other interface as follows: Public class ChildClass : BaseClass, BaseInterface{ ................ }) An abstract class can have shared state or functionality. An interface is only a promise to provide the state or functionality. A good abstract class will reduce the amount of code that has to be rewritten because it's functionality or state can be shared. The interface has no defined information to be shared

    • 0
  • Shashikant Patil
    Feb, 2017 27

    1) C# doesn't support Multiple inheritance ( means deriving a class from more than one class)... If your application supposed to have more than one class features at a time, For ex : we can inherit one class and other interface as follows: Public class ChildClass : BaseClass, BaseInterface{ ................ }) An abstract class can have shared state or functionality. An interface is only a promise to provide the state or functionality. A good abstract class will reduce the amount of code that has to be rewritten because it's functionality or state can be shared. The interface has no defined information to be shared

    • 0
  • Sanjay Kesarwani
    Jul, 2016 17

    Select Min(Salary) from ( Select top 5 Salary from table order by desc) T1

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS