We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 274504d commit d3f5747Copy full SHA for d3f5747
LeetCode SQL 50 Solution/176. Second Highest Salary.SQL
@@ -54,4 +54,13 @@ Output:
54
| SecondHighestSalary |
55
+---------------------+
56
| null |
57
-+---------------------+
++---------------------+
58
+
59
+WITH
60
+ RankedEmployees AS (
61
+ SELECT *, DENSE_RANK() OVER(ORDER BY salary DESC) AS `rank`
62
+ FROM Employee
63
+ )
64
+SELECT MAX(salary) AS SecondHighestSalary
65
+FROM RankedEmployees
66
+WHERE `rank` = 2;
0 commit comments