“在雇员表中查找第二高的工资的员工记录”SQL语句怎么写

        这个查询首先查找最高工资,然后将它从列表中排除。再查找最高工资。

非常明显,第二次返回的是第二高工资。

 

select top 1 * from employee where salary not int (select max(salary) from emplyee) order by salary desc

或者

select top 1 * from(select top 2 * from employee order by salary desc) as t order by salary asc

 

相关文章:

  • 2021-11-20
  • 2021-11-25
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-24
  • 2021-11-26
  • 2021-09-03
  • 2022-12-23
  • 2022-01-04
相关资源
相似解决方案