task_id
and subtasks_count
from the Tasks
table.task_id
and subtasks_count - 1
as long as subtasks_count
is greater than 1.task_id
and subtasks_count
as subtask_id
from the CTE.LEFT JOIN
with the Executed
table on task_id
and subtask_id
.WHERE
clause to filter out rows where Executed.subtask_id
is not NULL, which indicates that the subtask has not been executed.task_id
and the missing subtask_id
s.erDiagram Tasks { int task_id PK int subtasks_count } Executed { int task_id PK int subtask_id PK } Tasks ||--o{ Executed : "has"