drop table t_launches
ORA-00942: table or view does not existMore Details: https://docs.oracle.com/error-help/db/ora-00942
drop table t1
ORA-00942: table or view does not existMore Details: https://docs.oracle.com/error-help/db/ora-00942
drop table t2
ORA-00942: table or view does not existMore Details: https://docs.oracle.com/error-help/db/ora-00942
drop table t3
ORA-00942: table or view does not existMore Details: https://docs.oracle.com/error-help/db/ora-00942
create or replace view v_schedule as
select trunc(sysdate) + interval'1'minute * level as plan_date
from dual
connect by level <= 100000
View created.
create table t_launches as
select trunc(sysdate) + interval'1'minute * level + mod(abs(dbms_random.random), 60) * interval'1'second as launch_date
from dual
connect by level <= 1000
Table created.
create table t1 as
select plan_date, launch_date
from (
select plan_date,
lead(plan_date) over (order by plan_date) as next_plan_date
from v_schedule
)
left join t_launches
on (launch_date >= plan_date
and launch_date < next_plan_date)
Table created.
create table t2 as
select plan_date, launch_date
from (
select plan_date,
lead(plan_date) over (order by plan_date) as next_plan_date
from v_schedule
where plan_date <= trunc(sysdate) + interval'1'minute * 1000
)
left join t_launches
on (launch_date >= plan_date
and launch_date < next_plan_date)
union all
select plan_date, null
from v_schedule
where plan_date > trunc(sysdate) + interval'1'minute * 1000
Table created.
create table t3 as
select plan_date, launch_date
from (
select plan_date,
lead(plan_date) over (order by plan_date) as next_plan_date
from v_schedule
)
left join t_launches
on (plan_date <= trunc(sysdate) + interval'1'minute * 1000
and launch_date >= plan_date
and launch_date < next_plan_date)
Table created.