好的.....这是整个交易:
select appu.* from
(<quite a complex query here>) appu
where not exists
(select 1
from dual
where appu.ORA_APP IN
(select slot from
(select distinct slots.inizio,slots.fine from
(
with
params as (select 1900 fine from dual)
--params as (select app.ora_fine_attivita fine
-- where app.cod_agenda = appu.AGE
-- and app.ora_fine_attivita = appu.fine_fascia
--and app.data_appuntamento = appu.dataapp
--)
,
Intervals (inizio, EDM) as
( select 1700, 20 from dual
union all
select inizio+EDM, EDM from Intervals join params on
(inizio <= fine)
)
select * from Intervals join params on (inizio <= fine)
) slots
) slots
where slots.slot <= slots.fine
)
order by 1,2,3;
在不深入细节的情况下,where 条件应该删除那些“appu.ORA_APP”与应该在(外部)“slots”表中创建的记录之一匹配的记录。示例中使用的常量适用于记录子集(单个“appu.AGE”值),这就是为什么我应该对其进行参数化,以便使用注释的“参数”表(然后,在“间隔”表。
我知道从头开始分析并不容易,但我试图让它尽可能清晰;如果需要,请随时询问数字示例....谢谢