{ "data": { "question": { "questionId": "3943", "questionFrontendId": "3611", "categoryTitle": "Database", "boundTopicId": 3717951, "title": "Find Overbooked Employees", "titleSlug": "find-overbooked-employees", "content": "
Table: employees
\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| employee_id | int |\n| employee_name | varchar |\n| department | varchar |\n+---------------+---------+\nemployee_id is the unique identifier for this table.\nEach row contains information about an employee and their department.\n\n\n
Table: meetings
\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| meeting_id | int |\n| employee_id | int |\n| meeting_date | date |\n| meeting_type | varchar |\n| duration_hours| decimal |\n+---------------+---------+\nmeeting_id is the unique identifier for this table.\nEach row represents a meeting attended by an employee. meeting_type can be 'Team', 'Client', or 'Training'.\n\n\n
Write a solution to find employees who are meeting-heavy - employees who spend more than 50%
of their working time in meetings during any given week.
40
hours>
20
hours (50%
of 40
hours)2
weeksReturn the result table ordered by the number of meeting-heavy weeks in descending order, then by employee name in ascending order.
\n\nThe result format is in the following example.
\n\n\n
Example:
\n\nInput:
\n\nemployees table:
\n\n\n+-------------+----------------+-------------+\n| employee_id | employee_name | department |\n+-------------+----------------+-------------+\n| 1 | Alice Johnson | Engineering |\n| 2 | Bob Smith | Marketing |\n| 3 | Carol Davis | Sales |\n| 4 | David Wilson | Engineering |\n| 5 | Emma Brown | HR |\n+-------------+----------------+-------------+\n\n\n
meetings table:
\n\n\n+------------+-------------+--------------+--------------+----------------+\n| meeting_id | employee_id | meeting_date | meeting_type | duration_hours |\n+------------+-------------+--------------+--------------+----------------+\n| 1 | 1 | 2023-06-05 | Team | 8.0 |\n| 2 | 1 | 2023-06-06 | Client | 6.0 |\n| 3 | 1 | 2023-06-07 | Training | 7.0 |\n| 4 | 1 | 2023-06-12 | Team | 12.0 |\n| 5 | 1 | 2023-06-13 | Client | 9.0 |\n| 6 | 2 | 2023-06-05 | Team | 15.0 |\n| 7 | 2 | 2023-06-06 | Client | 8.0 |\n| 8 | 2 | 2023-06-12 | Training | 10.0 |\n| 9 | 3 | 2023-06-05 | Team | 4.0 |\n| 10 | 3 | 2023-06-06 | Client | 3.0 |\n| 11 | 4 | 2023-06-05 | Team | 25.0 |\n| 12 | 4 | 2023-06-19 | Client | 22.0 |\n| 13 | 5 | 2023-06-05 | Training | 2.0 |\n+------------+-------------+--------------+--------------+----------------+\n\n\n
Output:
\n\n\n+-------------+----------------+-------------+---------------------+\n| employee_id | employee_name | department | meeting_heavy_weeks |\n+-------------+----------------+-------------+---------------------+\n| 1 | Alice Johnson | Engineering | 2 |\n| 4 | David Wilson | Engineering | 2 |\n+-------------+----------------+-------------+---------------------+\n\n\n
Explanation:
\n\nThe result table is ordered by meeting_heavy_weeks in descending order, then by employee name in ascending order.
\n表:employees
\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| employee_id | int |\n| employee_name | varchar |\n| department | varchar |\n+---------------+---------+\nemployee_id 是这张表的唯一主键。\n每一行包含一个员工和他们部门的信息。\n\n\n
表:meetings
\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| meeting_id | int |\n| employee_id | int |\n| meeting_date | date |\n| meeting_type | varchar |\n| duration_hours| decimal |\n+---------------+---------+\nmeeting_id 是这张表的唯一主键。\n每一行表示一位员工参加的会议。meeting_type 可以是 'Team','Client' 或 'Training'。\n\n\n
编写一个解决方案来查找会议密集型的员工 - 在任何给定周内,花费超过 50%
工作时间在会议上的员工。
40
小时20
小时(40
小时工作时间的 50%
),则被视为会议密集型。2
周会议密集的员工返回结果表按会议密集周的数量降序排列,然后按员工姓名升序排列。结果格式如下所示。
\n\n\n\n
示例:
\n\nInput:
\n\nemployees 表:
\n\n\n+-------------+----------------+-------------+\n| employee_id | employee_name | department |\n+-------------+----------------+-------------+\n| 1 | Alice Johnson | Engineering |\n| 2 | Bob Smith | Marketing |\n| 3 | Carol Davis | Sales |\n| 4 | David Wilson | Engineering |\n| 5 | Emma Brown | HR |\n+-------------+----------------+-------------+\n\n\n
meetings 表:
\n\n\n+------------+-------------+--------------+--------------+----------------+\n| meeting_id | employee_id | meeting_date | meeting_type | duration_hours |\n+------------+-------------+--------------+--------------+----------------+\n| 1 | 1 | 2023-06-05 | Team | 8.0 |\n| 2 | 1 | 2023-06-06 | Client | 6.0 |\n| 3 | 1 | 2023-06-07 | Training | 7.0 |\n| 4 | 1 | 2023-06-12 | Team | 12.0 |\n| 5 | 1 | 2023-06-13 | Client | 9.0 |\n| 6 | 2 | 2023-06-05 | Team | 15.0 |\n| 7 | 2 | 2023-06-06 | Client | 8.0 |\n| 8 | 2 | 2023-06-12 | Training | 10.0 |\n| 9 | 3 | 2023-06-05 | Team | 4.0 |\n| 10 | 3 | 2023-06-06 | Client | 3.0 |\n| 11 | 4 | 2023-06-05 | Team | 25.0 |\n| 12 | 4 | 2023-06-19 | Client | 22.0 |\n| 13 | 5 | 2023-06-05 | Training | 2.0 |\n+------------+-------------+--------------+--------------+----------------+\n\n\n
输出:
\n\n\n+-------------+----------------+-------------+---------------------+\n| employee_id | employee_name | department | meeting_heavy_weeks |\n+-------------+----------------+-------------+---------------------+\n| 1 | Alice Johnson | Engineering | 2 |\n| 4 | David Wilson | Engineering | 2 |\n+-------------+----------------+-------------+---------------------+\n\n\n
解释:
\n\n结果表按 meeting_heavy_weeks 降序排列,然后按员工姓名升序排列。
\n\\u7248\\u672c\\uff1a mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\" Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\" Python 3.10 with Pandas 2.2.2 and NumPy 1.26.4<\\/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\",\"employee_name\",\"department\"],\"meetings\":[\"meeting_id\",\"employee_id\",\"meeting_date\",\"meeting_type\",\"duration_hours\"]},\"rows\":{\"employees\":[[1,\"Alice Johnson\",\"Engineering\"],[2,\"Bob Smith\",\"Marketing\"],[3,\"Carol Davis\",\"Sales\"],[4,\"David Wilson\",\"Engineering\"],[5,\"Emma Brown\",\"HR\"]],\"meetings\":[[1,1,\"2023-06-05\",\"Team\",8.0],[2,1,\"2023-06-06\",\"Client\",6.0],[3,1,\"2023-06-07\",\"Training\",7.0],[4,1,\"2023-06-12\",\"Team\",12.0],[5,1,\"2023-06-13\",\"Client\",9.0],[6,2,\"2023-06-05\",\"Team\",15.0],[7,2,\"2023-06-06\",\"Client\",8.0],[8,2,\"2023-06-12\",\"Training\",10.0],[9,3,\"2023-06-05\",\"Team\",4.0],[10,3,\"2023-06-06\",\"Client\",3.0],[11,4,\"2023-06-05\",\"Team\",25.0],[12,4,\"2023-06-19\",\"Client\",22.0],[13,5,\"2023-06-05\",\"Training\",2.0]]}}",
"__typename": "QuestionNode"
}
}
}MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"