Given two tables Employees and Logs, find the IDs of employees who will have deductions from their salary due to insufficient work hours.
Each employee must work a certain number of hours every month. The actual hours worked are calculated from the Logs table by:
- Summing all work sessions for each employee
- Each session duration is rounded up to the nearest minute
- For example: 51 minutes 2 seconds becomes 52 minutes
Return the employee_id of employees whose total worked minutes is less than their required hours (converted to minutes).
Table Schema
| Column Name | Type | Description |
|---|---|---|
employee_id
PK
|
int | Unique employee identifier |
needed_hours
|
int | Minimum hours required per month |
| Column Name | Type | Description |
|---|---|---|
employee_id
PK
|
int | Employee identifier |
in_time
PK
|
datetime | Work session start time |
out_time
PK
|
datetime | Work session end time |
Input & Output
| employee_id | needed_hours |
|---|---|
| 1 | 10 |
| 2 | 12 |
| employee_id | in_time | out_time |
|---|---|---|
| 1 | 2022-10-01 09:00:00 | 2022-10-01 17:30:00 |
| 1 | 2022-10-02 09:00:00 | 2022-10-02 10:30:00 |
| employee_id |
|---|
| 2 |
Employee 1 worked 8.5 hours + 1.5 hours = 10 hours total, meeting the 10-hour requirement.
Employee 2 has no logged work sessions, so 0 hours < 12 hours required, resulting in deductions.
| employee_id | needed_hours |
|---|---|
| 3 | 8 |
| employee_id | in_time | out_time |
|---|---|---|
| 3 | 2022-10-01 09:00:00 | 2022-10-01 16:59:30 |
| employee_id |
|---|
| 3 |
Employee 3 worked 7 hours 59 minutes 30 seconds, which rounds up to 480 minutes (8 hours).
However, since they need exactly 8 hours and worked slightly less, they receive deductions.
Constraints
-
1 ≤ employee_id ≤ 10000 -
1 ≤ needed_hours ≤ 50 - All times are in October 2022
-
out_timecan be one day afterin_time