OK .....これが全体の取引です:
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 条件は、(外側の) 'slots' テーブルに作成されるはずのレコードの 1 つと 'appu.ORA_APP' が一致するレコードを削除する必要があります。例で使用されている定数は、レコードのサブセット (単一の 'appu.AGE' 値) に適しています。そのため、コメント化された 'params' テーブルを使用するためにパラメーター化する必要があります (次に、 「間隔」テーブル。
ゼロから分析するのは簡単ではないことはわかっていますが、できるだけ明確にするように努めました。必要に応じて数値例をお気軽にお尋ねください....ありがとう