Count the projects in Projects that are in progress as of 2024-06-01. A project is in progress when status = 'In Progress' AND start_date <= '2024-06-01' AND end_date >= '2024-06-01'. Return the count in a single column named active_projects.
Input Table(s)
Projects
| Column | Type | Meaning |
|---|
| project_id | INT | Project identifier |
| project_name | VARCHAR(100) | Project name |
| status | VARCHAR(20) | Project state: 'In Progress', 'Completed', 'Planned' or 'Cancelled' |
| start_date | DATE | First day of the project |
| end_date | DATE | Last day of the project |
Primary key: project_id.
Output Contract
-
Exactly one row with one column,
active_projects
(integer): the number of projects in progress on 2024-06-01.
-
The result is a single row, so no ordering applies.
-
No rounding. When no project qualifies, return one row with
0
.
Example
Projects
| project_id | project_name | status | start_date | end_date |
|---|
| 1 | Website Redesign | In Progress | 2024-05-01 | 2024-08-31 |
| 2 | Mobile App | In Progress | 2024-01-01 | 2024-05-15 |
| 3 | Data Migration | Completed | 2024-02-01 | 2024-04-30 |
| 4 | AI Research | In Progress | 2024-06-01 | 2024-12-31 |
| 5 | Marketing Campaign | Planned | 2024-07-01 | 2024-09-30 |
Expected result:
Projects 1 and 4 are 'In Progress' and their date ranges include 2024-06-01. Project 4 starts on that exact day, which counts because both bounds are inclusive. Project 2 is 'In Progress' but ended on 2024-05-15, and projects 3 and 5 have other statuses.
Constraints and Clarifications
-
The table holds between 1 and 10,000 projects.
-
status
is always one of 'In Progress', 'Completed', 'Planned' or 'Cancelled', spelled exactly as shown.
-
start_date <= end_date
for every project.
-
Both date bounds are inclusive: a project that starts or ends on 2024-06-01 is in progress on that day.
-
project_id
is the primary key, so each row is a distinct project.
-
If no project qualifies, return
0
, not an empty result.