How to create select SQL statement that would produce "merged" dataset from two tables(Oracle DBMS)?

Posted by Roman Kagan on Stack Overflow See other posts from Stack Overflow or by Roman Kagan
Published on 2010-06-03T17:34:55Z Indexed on 2010/06/03 17:54 UTC
Read the original article Hit count: 184

Here's my original question: merging two data sets

Unfortunately I omitted some intircacies, that I'd like to elaborate here.

So I have two tables events_source_1 and events_source_2 tables. I have to produce the data set from those tables into resultant dataset (that I'd be able to insert into third table, but that's irrelevant).

events_source_1 contain historic event data and I have to do get the most recent event (for such I'm doing the following:

select event_type,b,c,max(event_date),null next_event_date
from events_source_1
group by event_type,b,c,event_date,null

events_source_2 contain the future event data and I have to do the following:

select event_type,b,c,null event_date, next_event_date
from events_source_2
where b>sysdate;

How to put outer join statement to fill the void (i.e. when same event_type,b,c found from event_source_2 then next_event_date will be filled with the first date found

GREATLY APPRECIATE FOR YOUR HELP IN ADVANCE.

© Stack Overflow or respective owner

Related posts about sql

Related posts about Oracle