{ "data": { "question": { "questionId": "176", "questionFrontendId": "176", "categoryTitle": "Database", "boundTopicId": 1177, "title": "Second Highest Salary", "titleSlug": "second-highest-salary", "content": "
Table: Employee
\n+-------------+------+\n| Column Name | Type |\n+-------------+------+\n| id | int |\n| salary | int |\n+-------------+------+\nid is the primary key (column with unique values) for this table.\nEach row of this table contains information about the salary of an employee.\n\n\n
\n\n
Write a solution to find the second highest salary from the Employee
table. If there is no second highest salary, return null (return None in Pandas)
.
The result format is in the following example.
\n\n\n
Example 1:
\n\n\nInput: \nEmployee table:\n+----+--------+\n| id | salary |\n+----+--------+\n| 1 | 100 |\n| 2 | 200 |\n| 3 | 300 |\n+----+--------+\nOutput: \n+---------------------+\n| SecondHighestSalary |\n+---------------------+\n| 200 |\n+---------------------+\n\n\n
Example 2:
\n\n\nInput: \nEmployee table:\n+----+--------+\n| id | salary |\n+----+--------+\n| 1 | 100 |\n+----+--------+\nOutput: \n+---------------------+\n| SecondHighestSalary |\n+---------------------+\n| null |\n+---------------------+\n\n", "translatedTitle": "第二高的薪水", "translatedContent": "
Employee
表:\n\n+-------------+------+\n| Column Name | Type |\n+-------------+------+\n| id | int |\n| salary | int |\n+-------------+------+\n在 SQL 中,id 是这个表的主键。\n表的每一行包含员工的工资信息。\n\n\n
\n\n
查询并返回 Employee
表中第二高的薪水 。如果不存在第二高的薪水,查询应该返回 null(Pandas 则返回 None)
。
查询结果如下例所示。
\n\n\n\n
示例 1:
\n\n\n输入:\nEmployee 表:\n+----+--------+\n| id | salary |\n+----+--------+\n| 1 | 100 |\n| 2 | 200 |\n| 3 | 300 |\n+----+--------+\n输出:\n+---------------------+\n| SecondHighestSalary |\n+---------------------+\n| 200 |\n+---------------------+\n\n\n
示例 2:
\n\n\n输入:\nEmployee 表:\n+----+--------+\n| id | salary |\n+----+--------+\n| 1 | 100 |\n+----+--------+\n输出:\n+---------------------+\n| SecondHighestSalary |\n+---------------------+\n| null |\n+---------------------+\n\n
\\u7248\\u672c\\uff1a mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\" Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\" Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\" PostgreSQL 16<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"Employee\":[\"id\",\"salary\"]},\"rows\":{\"Employee\":[[1,100],[2,200],[3,300]]}}\n{\"headers\":{\"Employee\":[\"id\",\"salary\"]},\"rows\":{\"Employee\":[[1,100]]}}",
"__typename": "QuestionNode"
}
}
}MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"