我有这个查询,它返回每天执行的任务:
SELECT B.gen_date, tarefa
FROM
(
SELECT DISTINCT A.gen_date
FROM
(
select *
from
(
select
adddate('2019-01-01',t4*10000 + t3*1000 + t2*100 + t1*10 + t0) gen_date
from
(select 0 t0 union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0,
(select 0 t1 union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1,
(select 0 t2 union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2,
(select 0 t3 union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3,
(select 0 t4 union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4
) v
where gen_date between '2019-01-01' and '2019-12-31'
UNION ALL
SELECT DATE_FORMAT(IniciarTarefa, '%Y-%m-%d')
FROM raddb.Tarefa
) AS A
) AS B
LEFT OUTER JOIN raddb.Tarefa
ON DATE_FORMAT(raddb.Tarefa.IniciarTarefa, '%Y-%m-%d') = B.gen_date
WHERE B.gen_date between '2019-06-01' AND '2019-06-10'
GROUP BY tarefa, B.gen_date, DATE_FORMAT(IniciarTarefa, '%Y-%m-%d')
ORDER BY gen_date
返回如下结果:
我有3种类型的任务(1、2和3)。 例如,在第1天返回仅执行任务2,第2天返回第1个任务,第3天执行所有任务。 然后,他希望它返回在第1天未执行任务1和3,没有执行第2天和第3天,第3天没有返回任何东西的消息,因为所有任务都已执行。我在图片中显示了示例,希望它返回什么: