{ "data": { "question": { "questionId": "2024", "questionFrontendId": "1873", "boundTopicId": null, "title": "Calculate Special Bonus", "titleSlug": "calculate-special-bonus", "content": "

Table: Employees

\n\n
\n+-------------+---------+\n| Column Name | Type    |\n+-------------+---------+\n| employee_id | int     |\n| name        | varchar |\n| salary      | int     |\n+-------------+---------+\nemployee_id is the primary key for this table.\nEach row of this table indicates the employee ID, employee name, and salary.\n
\n\n

 

\n\n

Write an SQL query 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 name does not start with the character 'M'. The bonus of an employee is 0 otherwise.

\n\n

Return the result table ordered by employee_id.

\n\n

The query 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": null, "translatedContent": null, "isPaidOnly": false, "difficulty": "Easy", "likes": 136, "dislikes": 3, "isLiked": null, "similarQuestions": "[]", "exampleTestcases": "{\"headers\":{\"Employees\":[\"employee_id\",\"name\",\"salary\"]},\"rows\":{\"Employees\":[[2,\"Meir\",3000],[3,\"Michael\",3800],[7,\"Addilyn\",7400],[8,\"Juan\",6100],[9,\"Kannon\",7700]]}}", "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" } ], "stats": "{\"totalAccepted\": \"16.7K\", \"totalSubmission\": \"18.6K\", \"totalAcceptedRaw\": 16689, \"totalSubmissionRaw\": 18578, \"acRate\": \"89.8%\"}", "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": "{\n \"mysql\": [\n \"Create table If Not Exists Employees (employee_id int, name varchar(30), salary int)\"\n ],\n \"mssql\": [\n \"Create table Employees (employee_id int, name varchar(30), salary int)\"\n ],\n \"oraclesql\": [\n \"Create table Employees (employee_id int, name varchar(30), salary int)\"\n ],\n \"database\": true\n}", "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, "enableTestMode": false, "enableDebugger": false, "envInfo": "{\"mysql\": [\"MySQL\", \"

MySQL 8.0.

\"], \"mssql\": [\"MS SQL Server\", \"

mssql server 2019.

\"], \"oraclesql\": [\"Oracle\", \"

Oracle Sql 11.2.

\"]}", "libraryUrl": null, "adminUrl": null, "challengeQuestion": null, "__typename": "QuestionNode" } } }