Sobes.tech
Senior

SQL task 3: List tasks that started or were ongoing in August 2025.

sobes.tech AI

Answer from AI

To list the tasks worked on in August 2025 (i.e., tasks that either started in August or were ongoing during this period), you need to check the intersection of the task's work period with August 2025.

Suppose we have a tasks table with fields task_id, start_date, and end_date (where end_date can be NULL if the task is not yet completed).

Example SQL query:

SELECT *
FROM tasks
WHERE
    -- Task started in August 2025
    (start_date >= '2025-08-01' AND start_date < '2025-09-01')
    
    OR

    -- Task started earlier but was ongoing in August (end_date >= 2025-08-01)
    (start_date < '2025-08-01' AND (end_date IS NULL OR end_date >= '2025-08-01'))
;

This query selects tasks whose work period overlaps with August 2025. If end_date is missing, it is considered that the task is still ongoing.

SQL task 3: List tasks that started or were ongoing… - sobes.tech