{ "data": { "question": { "questionId": "2024", "questionFrontendId": "1873", "categoryTitle": "Database", "boundTopicId": 794609, "title": "Calculate Special Bonus", "titleSlug": "calculate-special-bonus", "content": "
Table: Employees
\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| employee_id | int |\n| name | varchar |\n| salary | int |\n+-------------+---------+\nemployee_id is the primary key (column with unique values) for this table.\nEach row of this table indicates the employee ID, employee name, and salary.\n\n\n
\n\n
Write a solution to calculate the bonus of each employee. The bonus of an employee is 100%
of their salary if the ID of the employee is an odd number and the employee's name does not start with the character 'M'
. The bonus of an employee is 0
otherwise.
Return the result table ordered by employee_id
.
The result format is in the following example.
\n\n\n
Example 1:
\n\n\nInput: \nEmployees table:\n+-------------+---------+--------+\n| employee_id | name | salary |\n+-------------+---------+--------+\n| 2 | Meir | 3000 |\n| 3 | Michael | 3800 |\n| 7 | Addilyn | 7400 |\n| 8 | Juan | 6100 |\n| 9 | Kannon | 7700 |\n+-------------+---------+--------+\nOutput: \n+-------------+-------+\n| employee_id | bonus |\n+-------------+-------+\n| 2 | 0 |\n| 3 | 0 |\n| 7 | 7400 |\n| 8 | 0 |\n| 9 | 7700 |\n+-------------+-------+\nExplanation: \nThe employees with IDs 2 and 8 get 0 bonus because they have an even employee_id.\nThe employee with ID 3 gets 0 bonus because their name starts with 'M'.\nThe rest of the employees get a 100% bonus.\n\n", "translatedTitle": "计算特殊奖金", "translatedContent": "
表: Employees
\n+-------------+---------+\n| 列名 | 类型 |\n+-------------+---------+\n| employee_id | int |\n| name | varchar |\n| salary | int |\n+-------------+---------+\nemployee_id 是这个表的主键(具有唯一值的列)。\n此表的每一行给出了雇员id ,名字和薪水。\n\n\n
\n\n
编写解决方案,计算每个雇员的奖金。如果一个雇员的 id 是 奇数 并且他的名字不是以 'M'
开头,那么他的奖金是他工资的 100%
,否则奖金为 0
。
返回的结果按照 employee_id
排序。
返回结果格式如下面的例子所示。
\n\n\n\n
示例 1:
\n\n\n输入:\nEmployees 表:\n+-------------+---------+--------+\n| employee_id | name | salary |\n+-------------+---------+--------+\n| 2 | Meir | 3000 |\n| 3 | Michael | 3800 |\n| 7 | Addilyn | 7400 |\n| 8 | Juan | 6100 |\n| 9 | Kannon | 7700 |\n+-------------+---------+--------+\n输出:\n+-------------+-------+\n| employee_id | bonus |\n+-------------+-------+\n| 2 | 0 |\n| 3 | 0 |\n| 7 | 7400 |\n| 8 | 0 |\n| 9 | 7700 |\n+-------------+-------+\n解释:\n因为雇员id是偶数,所以雇员id 是2和8的两个雇员得到的奖金是0。\n雇员id为3的因为他的名字以'M'开头,所以,奖金是0。\n其他的雇员得到了百分之百的奖金。\n", "isPaidOnly": false, "difficulty": "Easy", "likes": 192, "dislikes": 0, "isLiked": null, "similarQuestions": "[]", "contributors": [], "langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}", "topicTags": [ { "name": "Database", "slug": "database", "translatedName": "数据库", "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": [ { "lang": "MySQL", "langSlug": "mysql", "code": "# Write your MySQL query statement below", "__typename": "CodeSnippetNode" }, { "lang": "MS SQL Server", "langSlug": "mssql", "code": "/* Write your T-SQL query statement below */", "__typename": "CodeSnippetNode" }, { "lang": "Oracle", "langSlug": "oraclesql", "code": "/* Write your PL/SQL query statement below */", "__typename": "CodeSnippetNode" }, { "lang": "Pandas", "langSlug": "pythondata", "code": "import pandas as pd\n\ndef calculate_special_bonus(employees: pd.DataFrame) -> pd.DataFrame:\n ", "__typename": "CodeSnippetNode" }, { "lang": "PostgreSQL", "langSlug": "postgresql", "code": "-- Write your PostgreSQL query statement below", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"90K\", \"totalSubmission\": \"145.4K\", \"totalAcceptedRaw\": 90006, \"totalSubmissionRaw\": 145376, \"acRate\": \"61.9%\"}", "hints": [], "solution": null, "status": null, "sampleTestCase": "{\"headers\":{\"Employees\":[\"employee_id\",\"name\",\"salary\"]},\"rows\":{\"Employees\":[[2,\"Meir\",3000],[3,\"Michael\",3800],[7,\"Addilyn\",7400],[8,\"Juan\",6100],[9,\"Kannon\",7700]]}}", "metaData": "{\"mysql\":[\"Create table If Not Exists Employees (employee_id int, name varchar(30), salary int)\"],\"mssql\":[\"Create table Employees (employee_id int, name varchar(30), salary int)\"],\"oraclesql\":[\"Create table Employees (employee_id int, name varchar(30), salary int)\"],\"database\":true,\"name\":\"calculate_special_bonus\",\"pythondata\":[\"Employees = pd.DataFrame([], columns=['employee_id', 'name', 'salary']).astype({'employee_id':'int64', 'name':'object', 'salary':'int64'})\"],\"manual\":false,\"postgresql\":[\"Create table If Not Exists Employees (employee_id int, name varchar(30), salary int)\"],\"database_schema\":{\"Employees\":{\"employee_id\":\"INT\",\"name\":\"VARCHAR(30)\",\"salary\":\"INT\"}}}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [ "Create table If Not Exists Employees (employee_id int, name varchar(30), salary int)", "Truncate table Employees", "insert into Employees (employee_id, name, salary) values ('2', 'Meir', '3000')", "insert into Employees (employee_id, name, salary) values ('3', 'Michael', '3800')", "insert into Employees (employee_id, name, salary) values ('7', 'Addilyn', '7400')", "insert into Employees (employee_id, name, salary) values ('8', 'Juan', '6100')", "insert into Employees (employee_id, name, salary) values ('9', 'Kannon', '7700')" ], "enableRunCode": true, "envInfo": "{\"mysql\":[\"MySQL\",\"
\\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\":{\"Employees\":[\"employee_id\",\"name\",\"salary\"]},\"rows\":{\"Employees\":[[2,\"Meir\",3000],[3,\"Michael\",3800],[7,\"Addilyn\",7400],[8,\"Juan\",6100],[9,\"Kannon\",7700]]}}",
"__typename": "QuestionNode"
}
}
}MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"