2022-03-27 18:46:20 +08:00
< p > Table: < code > Employee< / code > < / p >
< pre >
+-------------+------+
| Column Name | Type |
+-------------+------+
| id | int |
| salary | int |
+-------------+------+
2023-12-09 18:42:21 +08:00
id is the primary key (column with unique values) for this table.
2022-03-27 18:46:20 +08:00
Each row of this table contains information about the salary of an employee.
< / pre >
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > Write a solution to find the second highest salary from the < code > Employee< / code > table. If there is no second highest salary, return < code > null (return None in Pandas)< / code > .< / p >
2022-03-27 18:46:20 +08:00
2023-12-09 18:42:21 +08:00
< p > The result format is in the following example.< / p >
2022-03-27 18:46:20 +08:00
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-03-27 18:46:20 +08:00
< pre >
< strong > Input:< / strong >
Employee table:
+----+--------+
| id | salary |
+----+--------+
| 1 | 100 |
| 2 | 200 |
| 3 | 300 |
+----+--------+
< strong > Output:< / strong >
+---------------------+
| SecondHighestSalary |
+---------------------+
| 200 |
+---------------------+
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2022-03-27 18:46:20 +08:00
< pre >
< strong > Input:< / strong >
Employee table:
+----+--------+
| id | salary |
+----+--------+
| 1 | 100 |
+----+--------+
< strong > Output:< / strong >
+---------------------+
| SecondHighestSalary |
+---------------------+
| null |
+---------------------+
< / pre >