Write a SQL query to get the second highest salary from the Employee table.
题意
编写一个 SQL 查询,获取 Employee 表中第二高的薪水(Salary) 。
解题
取第二高的薪水,可以用max()函数取出最大值,然后排除这个最大值,再取一次最大值即可。这题还有其他方法,大家可以参考下面官方链接看看:https://leetcode-cn.com/problems/second-highest-salary/solution/di-er-gao-de-xin-shui-by-leetcode/select max(a.salary) as SecondHighestSalary
from Employee a
where a.salary <> (select max(a.salary) from Employee a)