How to get second-highest salary employees in a table

后端 未结 30 957
离开以前
离开以前 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:49

    this is the simple query .. if u want the second minimum then just change the max to min and change the less than(<) sign to grater than(>).

        select max(column_name) from table_name where column_name<(select max(column_name) from table_name)
    

提交回复
热议问题