How to get second-highest salary employees in a table

后端 未结 30 951
离开以前
离开以前 2020-12-23 20:15

It\'s a question I got this afternoon:

There a table contains ID, Name, and Salary of Employees, get names of the second-highest salary employees, in SQL Server

30条回答
  •  無奈伤痛
    2020-12-23 20:59

    Can we also use

    select e2.max(sal), e2.name
    from emp e2
    where (e2.sal <(Select max (Salary) from empo el))
    group by e2.name
    

    Please let me know what is wrong with this approach

提交回复
热议问题