Nav: << previous: 175.组合两个表 | next: 177.第N高的薪水 >>
Description
tab: English
<p>Table: <code>Employee</code></p>
<pre>
+-------------+------+
| Column Name | Type |
+-------------+------+
| id | int |
| salary | int |
+-------------+------+
id is the primary key (column with unique values) for this table.
Each row of this table contains information about the salary of an employee.
</pre>
<p> </p>
<p>Write a solution to find the second highest <strong>distinct</strong> salary from the <code>Employee</code> table. If there is no second highest salary, return <code>null (return None in Pandas)</code>.</p>
<p>The result format is in the following example.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong>
Employee table:
+----+--------+
| id | salary |
+----+--------+
| 1 | 100 |
| 2 | 200 |
| 3 | 300 |
+----+--------+
<strong>Output:</strong>
+---------------------+
| SecondHighestSalary |
+---------------------+
| 200 |
+---------------------+
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong>
Employee table:
+----+--------+
| id | salary |
+----+--------+
| 1 | 100 |
+----+--------+
<strong>Output:</strong>
+---------------------+
| SecondHighestSalary |
+---------------------+
| null |
+---------------------+
</pre>
---
[submissions](https://leetcode.com/problems/second-highest-salary/submissions/) | [solutions](https://leetcode.com/problems/second-highest-salary/solutions/)
tab: 中文
<code>Employee</code> 表:
<div class="original__bRMd">
<div>
<pre>
+-------------+------+
| Column Name | Type |
+-------------+------+
| id | int |
| salary | int |
+-------------+------+
id 是这个表的主键。
表的每一行包含员工的工资信息。
</pre>
<p> </p>
<p>查询并返回 <code>Employee</code> 表中第二高的 <b>不同</b> 薪水 。如果不存在第二高的薪水,查询应该返回 <code>null(Pandas 则返回 None)</code> 。</p>
<p>查询结果如下例所示。</p>
<p> </p>
<p><strong>示例 1:</strong></p>
<pre>
<strong>输入:</strong>
Employee 表:
+----+--------+
| id | salary |
+----+--------+
| 1 | 100 |
| 2 | 200 |
| 3 | 300 |
+----+--------+
<strong>输出:</strong>
+---------------------+
| SecondHighestSalary |
+---------------------+
| 200 |
+---------------------+
</pre>
<p><strong>示例 2:</strong></p>
<pre>
<strong>输入:</strong>
Employee 表:
+----+--------+
| id | salary |
+----+--------+
| 1 | 100 |
+----+--------+
<strong>输出:</strong>
+---------------------+
| SecondHighestSalary |
+---------------------+
| null |
+---------------------+
</pre>
</div>
</div>
---
[提交记录](https://leetcode.cn/problems/second-highest-salary/submissions/) | [题解](https://leetcode.cn/problems/second-highest-salary/solution/)
Solutions & Notes
properties:
note.updated:
displayName: Last Updated
note.relative_links:
displayName: Related Links
note.desc:
displayName: Description
note.grade:
displayName: Rating
note.program_language:
displayName: Language
note.time_complexity:
displayName: TC
note.space_complexity:
displayName: SC
views:
- type: table
name: Solutions & Notes
filters:
and:
- file.hasLink(this.file)
- file.tags.containsAny("leetcode/solution", "leetcode/note")
order:
- file.name
- desc
- program_language
- time_complexity
- space_complexity
- grade
- relative_links
- updated
sort:
- property: grade
direction: ASC
- property: time_complexity
direction: ASC
- property: program_language
direction: ASC
columnSize:
file.name: 104
note.space_complexity: 65
note.grade: 126
Similar Problems
properties:
note.lcTopics:
displayName: Topics
note.lcAcRate:
displayName: AC Rate
note.favorites:
displayName: Favorites
note.grade:
displayName: Rating
note.translatedTitle:
displayName: Title (CN)
note.lcDifficulty:
displayName: Difficulty
views:
- type: table
name: Similar Problems
filters:
and:
- file.hasLink(this.file)
- similarQuestions.contains(this.file)
order:
- file.name
- translatedTitle
- lcTopics
- lcDifficulty
- lcAcRate
- grade
- favorites
sort:
- property: file.name
direction: ASC
- property: lcTopics
direction: DESC
columnSize:
note.translatedTitle: 240
note.lcTopics: 347
note.lcAcRate: 75
note.grade: 122