![7{(]BNZDCSVZ8@N]NKY@XW.png
还是递归查询的使用,只不过这次里面有2个变量,另外尽量避免用not in, 用了经常超时
with recursive t(task_id, subtask_id) as
(
select task_id, subtasks_count from Tasks
union all
select task_id, subtask_id - 1 from t where subtask_id >= 2
)
select t.* FROM t left join Executed E
on (t.task_id,t.subtask_id) = (E.task_id,E.subtask_id)
where E.task_id is null