🤔 문제 분석
1) 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.
💡 풀이
SELECT MAX(salary) AS SecondHighestSalary
FROM Employee
WHERE Salary <> (SELECT MAX(salary) FROM Employee)
✍️ check point!
서브쿼리
'코딩테스트 > 리트코드 SQL' 카테고리의 다른 글
[리트코드/SQL] 16. Customer Who Visited but Did Not Make Any Transactions (1581) (0) | 2022.12.18 |
---|---|
[리트코드/SQL] 15. Combine Two Tables (175) (0) | 2022.12.18 |
[리트코드/SQL] 13. Tree node (608) (0) | 2022.12.16 |
[리트코드/SQL] 12. Rearrange Products Table (1795) (0) | 2022.12.16 |
[리트코드/SQL] 11. Employees With Missing Information (1965) (0) | 2022.12.16 |
댓글