Skip to content

Commit 274504d

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

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
176. Second Highest Salary
2+
Solved
3+
Medium
4+
Topics
5+
Companies
6+
SQL Schema
7+
Pandas Schema
8+
Table: Employee
9+
10+
+-------------+------+
11+
| Column Name | Type |
12+
+-------------+------+
13+
| id | int |
14+
| salary | int |
15+
+-------------+------+
16+
id is the primary key (column with unique values) for this table.
17+
Each row of this table contains information about the salary of an employee.
18+
19+
20+
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).
21+
22+
The result format is in the following example.
23+
24+
25+
26+
Example 1:
27+
28+
Input:
29+
Employee table:
30+
+----+--------+
31+
| id | salary |
32+
+----+--------+
33+
| 1 | 100 |
34+
| 2 | 200 |
35+
| 3 | 300 |
36+
+----+--------+
37+
Output:
38+
+---------------------+
39+
| SecondHighestSalary |
40+
+---------------------+
41+
| 200 |
42+
+---------------------+
43+
Example 2:
44+
45+
Input:
46+
Employee table:
47+
+----+--------+
48+
| id | salary |
49+
+----+--------+
50+
| 1 | 100 |
51+
+----+--------+
52+
Output:
53+
+---------------------+
54+
| SecondHighestSalary |
55+
+---------------------+
56+
| null |
57+
+---------------------+

0 commit comments

Comments
 (0)