Unique Work Days
Start Timer
0:00:00
You have a table containing information about the time that employees have worked on a project.
Write a query to find how many unique calendar days each employee worked. Order your query by the employee_id.
Example:
An employee worked on two projects, and recorded their time like this:
| employee_id | project_id | start_date | end_date |
|---|---|---|---|
| 1 | 1 | 2024-01-01 | 2024-01-06 |
| 1 | 2 | 2024-01-03 | 2024-01-07 |
The number of unique calendar days is therefore 7.
Input:
projects table
| Columns | Type |
|---|---|
employee_id |
INTEGER |
project_id |
INTEGER |
start_date |
DATE |
end_date |
DATE |
Output:
| Columns | Type |
|---|---|
employee_id |
INTEGER |
unique_days_worked |
INTEGER |
.
.
.
.
.
.
.
.
.
Comments