编写一个 SQL 查询,获取 Employee 表中第二高的薪水(Salary) 。

+----+--------+
| Id | Salary |
+----+--------+
| 1 | 100 |
| 2 | 200 |
| 3 | 300 |
+----+--------+
例如上述 Employee 表,SQL查询应该返回 200 作为第二高的薪水。如果不存在第二高的薪水,那么查询应返回 null。

+---------------------+
| SecondHighestSalary |
+---------------------+
| 200 |
+---------------------+

来源:力扣(LeetCode)

select max(Salary) SecondHighestSalary
from employee
where
salary<(select max(salary) from employee)
 
 
 
select (select distinct salary from Employee order by salary desc limit 1,1) as SecondHighestSalary 

相关文章:

  • 2021-12-28
  • 2022-12-23
  • 2021-05-21
  • 2021-05-16
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
  • 2021-06-12
猜你喜欢
  • 2021-05-24
  • 2021-12-04
  • 2022-01-04
  • 2021-08-13
  • 2021-10-24
  • 2021-08-28
  • 2021-06-17
相关资源
相似解决方案