Q. Write an SQL query to report the second highest salary from the Employee table. If there is no second highest salary, the query should report null.
# Solution
두번째로 salary가 큰 것을 가져오는거라 처음엔 window function을 사용해서 가져오려 했으나 max 를 사용하여 깔끔하게 해결
select max(salary) as SecondHighestSalary
from employee
where salary < (select max(salary) from employee)
https://leetcode.com/problems/second-highest-salary/
Second Highest Salary - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com