Skip to content

Commit d3f5747

Browse files
committed
Update 176. Second Highest Salary.SQL
1 parent 274504d commit d3f5747

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

LeetCode SQL 50 Solution/176. Second Highest Salary.SQL

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,13 @@ Output:
5454
| SecondHighestSalary |
5555
+---------------------+
5656
| null |
57-
+---------------------+
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

Comments
 (0)