You are given two tables: Tasks and Executed.
The Tasks table contains information about tasks and their subtask counts. Each task is divided into subtasks labeled from 1 to subtasks_count.
The Executed table contains records of which subtasks were successfully executed for each task.
Write a SQL query to find all the missing subtasks for each task - that is, the subtasks that were supposed to run but did not execute.
Return the result table in any order.
Table Schema
| Column Name | Type | Description |
|---|---|---|
task_id
PK
|
int | Unique identifier for each task |
subtasks_count
|
int | Total number of subtasks for this task (2-20) |
| Column Name | Type | Description |
|---|---|---|
task_id
PK
|
int | Task identifier (foreign key to Tasks) |
subtask_id
PK
|
int | ID of the executed subtask |
Input & Output
| task_id | subtasks_count |
|---|---|
| 1 | 3 |
| 2 | 2 |
| 3 | 4 |
| task_id | subtask_id |
|---|---|
| 1 | 2 |
| 3 | 1 |
| 3 | 3 |
| 3 | 4 |
| task_id | subtask_id |
|---|---|
| 1 | 1 |
| 1 | 3 |
| 2 | 1 |
| 2 | 2 |
Task 1 has 3 subtasks (1,2,3) but only subtask 2 executed, so subtasks 1 and 3 are missing. Task 2 has 2 subtasks (1,2) but none executed, so both are missing. Task 3 has 4 subtasks and executed 1,3,4, so only subtask 2 is missing (but it's not in our output, indicating all expected subtasks for task 3 were covered).
| task_id | subtasks_count |
|---|---|
| 1 | 2 |
| task_id | subtask_id |
|---|---|
| 1 | 1 |
| 1 | 2 |
| task_id | subtask_id |
|---|
Task 1 has 2 subtasks and both subtasks 1 and 2 were executed, so there are no missing subtasks. The result is empty.
Constraints
-
1 ≤ task_id ≤ 1000 -
2 ≤ subtasks_count ≤ 20 -
subtask_id ≤ subtasks_countfor each task_id