문제
https://leetcode.com/problems/second-highest-salary/
Write a solution to find the second highest salary from the Employee table. If there is no second highest salary, return null (return None in Pandas).
The result format is in the following example.
풀이
SELECT MAX(salary) AS SecondHighestSalary
FROM Employee
WHERE salary <> (
SELECT MAX(salary)
FROM Employee
)
오답 이유
1. 서브 쿼리가 바로 떠오르지 않았음.
2. 가장 큰 값을 제외한 나머지 숫자들에서 최대값을 생각하긴 했지만 어떻게 구현해야 할지 몰랐음.
'취준 > 코팅 테스트' 카테고리의 다른 글
[LeetCode] - 180. Consecutive Numbers (0) | 2024.03.27 |
---|---|
[LeetCode] - 1527. Patients With a Condition (0) | 2024.03.26 |
[LeetCode] - 586. Customer Placing the Largest Number of Orders (0) | 2024.03.25 |
[LeetCode] - 577.Employee Bonus (0) | 2024.03.18 |
[LeetCode] 1407. Top Travellers (0) | 2024.03.12 |