题目链接:点击打开链接
题目大意:略。
解题思路:略。
AC 代码
-- 解决方案(1) 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-1>0 ) SELECT * FROM t left join Executed using(task_id, subtask_id) WHERE Executed.subtask_id is null ORDER BY task_id, subtask_id -- 解决方案(2) WITH RECURSIVE t AS( SELECT 1 num UNION ALL SELECT num + 1 FROM t WHERE num < (SELECT MAX(subtasks_count) maxn FROM Tasks) ) SELECT task_id, num subtask_id FROM Tasks JOIN t WHERE subtasks_count >= num AND (task_id, num) NOT IN (SELECT * FROM Executed) ORDER BY task_id, num