Find max and second max salary for a employee table MySQL

前端 未结 30 1958
忘掉有多难
忘掉有多难 2020-12-12 21:19

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         


        
30条回答
  •  无人及你
    2020-12-12 21:39

    Try below Query, was working for me to find Nth highest number salary. Just replace your number with nth_No

    Select DISTINCT TOP 1 salary
    from 
    (Select DISTINCT TOP *nth_No* salary
    from Employee
    ORDER BY Salary DESC)
    Result
    ORDER BY Salary
    

提交回复
热议问题