1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode/originData/department-top-three-salaries.json
2023-12-09 19:57:46 +08:00

102 lines
9.5 KiB
JSON

{
"data": {
"question": {
"questionId": "185",
"questionFrontendId": "185",
"boundTopicId": null,
"title": "Department Top Three Salaries",
"titleSlug": "department-top-three-salaries",
"content": "<p>Table: <code>Employee</code></p>\n\n<pre>\n+--------------+---------+\n| Column Name | Type |\n+--------------+---------+\n| id | int |\n| name | varchar |\n| salary | int |\n| departmentId | int |\n+--------------+---------+\nid is the primary key (column with unique values) for this table.\ndepartmentId is a foreign key (reference column) of the ID from the <code>Department </code>table.\nEach row of this table indicates the ID, name, and salary of an employee. It also contains the ID of their department.\n</pre>\n\n<p>&nbsp;</p>\n\n<p>Table: <code>Department</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| id | int |\n| name | varchar |\n+-------------+---------+\nid is the primary key (column with unique values) for this table.\nEach row of this table indicates the ID of a department and its name.\n</pre>\n\n<p>&nbsp;</p>\n\n<p>A company&#39;s executives are interested in seeing who earns the most money in each of the company&#39;s departments. A <strong>high earner</strong> in a department is an employee who has a salary in the <strong>top three unique</strong> salaries for that department.</p>\n\n<p>Write a solution to find the employees who are <strong>high earners</strong> in each of the departments.</p>\n\n<p>Return the result table <strong>in any order</strong>.</p>\n\n<p>The&nbsp;result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nEmployee table:\n+----+-------+--------+--------------+\n| id | name | salary | departmentId |\n+----+-------+--------+--------------+\n| 1 | Joe | 85000 | 1 |\n| 2 | Henry | 80000 | 2 |\n| 3 | Sam | 60000 | 2 |\n| 4 | Max | 90000 | 1 |\n| 5 | Janet | 69000 | 1 |\n| 6 | Randy | 85000 | 1 |\n| 7 | Will | 70000 | 1 |\n+----+-------+--------+--------------+\nDepartment table:\n+----+-------+\n| id | name |\n+----+-------+\n| 1 | IT |\n| 2 | Sales |\n+----+-------+\n<strong>Output:</strong> \n+------------+----------+--------+\n| Department | Employee | Salary |\n+------------+----------+--------+\n| IT | Max | 90000 |\n| IT | Joe | 85000 |\n| IT | Randy | 85000 |\n| IT | Will | 70000 |\n| Sales | Henry | 80000 |\n| Sales | Sam | 60000 |\n+------------+----------+--------+\n<strong>Explanation:</strong> \nIn the IT department:\n- Max earns the highest unique salary\n- Both Randy and Joe earn the second-highest unique salary\n- Will earns the third-highest unique salary\n\nIn the Sales department:\n- Henry earns the highest salary\n- Sam earns the second-highest salary\n- There is no third-highest salary as there are only two employees\n</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 1885,
"dislikes": 225,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\": {\"Employee\": [\"id\", \"name\", \"salary\", \"departmentId\"], \"Department\": [\"id\", \"name\"]}, \"rows\": {\"Employee\": [[1, \"Joe\", 85000, 1], [2, \"Henry\", 80000, 2], [3, \"Sam\", 60000, 2], [4, \"Max\", 90000, 1], [5, \"Janet\", 69000, 1], [6, \"Randy\", 85000, 1], [7, \"Will\", 70000, 1]], \"Department\": [[1, \"IT\"], [2, \"Sales\"]]}}",
"categoryTitle": "Database",
"contributors": [],
"topicTags": [
{
"name": "Database",
"slug": "database",
"translatedName": null,
"__typename": "TopicTagNode"
}
],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "MySQL",
"langSlug": "mysql",
"code": "# Write your MySQL query statement below\n",
"__typename": "CodeSnippetNode"
},
{
"lang": "MS SQL Server",
"langSlug": "mssql",
"code": "/* Write your T-SQL query statement below */\n",
"__typename": "CodeSnippetNode"
},
{
"lang": "Oracle",
"langSlug": "oraclesql",
"code": "/* Write your PL/SQL query statement below */\n",
"__typename": "CodeSnippetNode"
},
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef top_three_salaries(employee: pd.DataFrame, department: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
},
{
"lang": "PostgreSQL",
"langSlug": "postgresql",
"code": "-- Write your PostgreSQL query statement below\n",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"269.4K\", \"totalSubmission\": \"524.4K\", \"totalAcceptedRaw\": 269442, \"totalSubmissionRaw\": 524432, \"acRate\": \"51.4%\"}",
"hints": [],
"solution": {
"id": "212",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\": {\"Employee\": [\"id\", \"name\", \"salary\", \"departmentId\"], \"Department\": [\"id\", \"name\"]}, \"rows\": {\"Employee\": [[1, \"Joe\", 85000, 1], [2, \"Henry\", 80000, 2], [3, \"Sam\", 60000, 2], [4, \"Max\", 90000, 1], [5, \"Janet\", 69000, 1], [6, \"Randy\", 85000, 1], [7, \"Will\", 70000, 1]], \"Department\": [[1, \"IT\"], [2, \"Sales\"]]}}",
"metaData": "{\"mysql\": [\"Create table If Not Exists Employee (id int, name varchar(255), salary int, departmentId int)\", \"Create table If Not Exists Department (id int, name varchar(255))\"], \"mssql\": [\"Create table Employee (id int, name varchar(255), salary int, departmentId int)\", \"Create table Department (id int, name varchar(255))\"], \"oraclesql\": [\"Create table Employee (id int, name varchar(255), salary int, departmentId int)\", \"Create table Department (id int, name varchar(255))\"], \"database\": true, \"name\": \"top_three_salaries\", \"pythondata\": [\"Employee = pd.DataFrame([], columns=['id', 'name', 'salary', 'departmentId']).astype({'id':'Int64', 'name':'object', 'salary':'Int64', 'departmentId':'Int64'})\", \"Department = pd.DataFrame([], columns=['id', 'name']).astype({'id':'Int64', 'name':'object'})\"], \"postgresql\": [\"Create table If Not Exists Employee (id int, name varchar(255), salary int, departmentId int)\\n\", \"Create table If Not Exists Department (id int, name varchar(255))\\n\"], \"database_schema\": {\"Employee\": {\"id\": \"INT\", \"name\": \"VARCHAR(255)\", \"salary\": \"INT\", \"departmentId\": \"INT\"}, \"Department\": {\"id\": \"INT\", \"name\": \"VARCHAR(255)\"}}}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table If Not Exists Employee (id int, name varchar(255), salary int, departmentId int)",
"Create table If Not Exists Department (id int, name varchar(255))",
"Truncate table Employee",
"insert into Employee (id, name, salary, departmentId) values ('1', 'Joe', '85000', '1')",
"insert into Employee (id, name, salary, departmentId) values ('2', 'Henry', '80000', '2')",
"insert into Employee (id, name, salary, departmentId) values ('3', 'Sam', '60000', '2')",
"insert into Employee (id, name, salary, departmentId) values ('4', 'Max', '90000', '1')",
"insert into Employee (id, name, salary, departmentId) values ('5', 'Janet', '69000', '1')",
"insert into Employee (id, name, salary, departmentId) values ('6', 'Randy', '85000', '1')",
"insert into Employee (id, name, salary, departmentId) values ('7', 'Will', '70000', '1')",
"Truncate table Department",
"insert into Department (id, name) values ('1', 'IT')",
"insert into Department (id, name) values ('2', 'Sales')"
],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": false,
"envInfo": "{\"mysql\": [\"MySQL\", \"<p><code>MySQL 8.0</code>.</p>\"], \"mssql\": [\"MS SQL Server\", \"<p><code>mssql server 2019</code>.</p>\"], \"oraclesql\": [\"Oracle\", \"<p><code>Oracle Sql 11.2</code>.</p>\"], \"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"], \"postgresql\": [\"PostgreSQL\", \"<p>PostgreSQL 16</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}