61. Second Highest Salary
https://leetcode.com/problems/second-highest-salary/submissions/1475023239/
Write a solution to find the second highest distinct salary from the Employee table. If there is no second highest salary, return null (return None in Pandas).
WITH temp AS ( SELECT salary, dense_rank() over(ORDER BY salary DESC) as rnk FROM Employee ) SELECT IF(max(rnk)<2, null, salary) SecondHighestSalary FROM temp WHERE rnk = 2
dense_rank()를 사용한 이유 - 연속된 순위를 구하기 위해