Solutin#1
# Write your MySQL query statement belowSELECT MAX(Salary) AS SecondHighestSalaryFROM EmployeeWHERE Salary < (SELECT MAX(Salary) FROM Employee)#Using max() will return a NULL #if the value doesn't exist. #So there is no need to UNION a NULL. #Of course, if the second highest value is guaranteed to exist, using LIMIT 1,1 will be the best answer.Solution#2
SELECT (SELECT DISTINCT SalaryFROM Employee ORDER BY Salary DESC LIMIT 1 OFFSET 1) AS SecondHighestSalary #利用了Limit 1,同时在外圈加一圈选择满足了Null的情况新闻热点
疑难解答