{ "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 for this table.\nEach row of this table contains information about the salary of an employee.\n\n\n
\n\n
Write an SQL query to report the second highest salary from the Employee
table. If there is no second highest salary, the query should report null
.
The query 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+-------------+------+\nid 是这个表的主键。\n表的每一行包含员工的工资信息。\n\n\n
\n\n
编写一个 SQL 查询,获取并返回 Employee
表中第二高的薪水 。如果不存在第二高的薪水,查询应该返回 null
。
查询结果如下例所示。
\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>\"]}",
"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\",\"