Home » SQL & PL/SQL » SQL & PL/SQL » Compare sequences in two tables to find missing sequence no
Compare sequences in two tables to find missing sequence no [message #190209] Tue, 29 August 2006 13:21 Go to next message
coolguy01
Messages: 64
Registered: August 2006
Member
hey i have two tables with a similar type of column that conatin some sequence numbers. The second table is actually a table which conatins the missing sequence nos in the first table. Even then there may still be some more nos in the sequence missing..... so how do i compare both the tables to find the missing sequence nos or rows from both the table?? how do i compare the two tables??
Re: Compare sequences in two tables to find missing sequence no [message #190212 is a reply to message #190209] Tue, 29 August 2006 13:25 Go to previous messageGo to next message
ebrian
Messages: 2794
Registered: April 2006
Senior Member
Duplicate post http://www.orafaq.com/forum/t/68631/85219/.

It would really help if you provided craete scripts and sample data.
Re: Compare sequences in two tables to find missing sequence no [message #190213 is a reply to message #190212] Tue, 29 August 2006 13:50 Go to previous messageGo to next message
coolguy01
Messages: 64
Registered: August 2006
Member
hey ebrain its already two existing tables containing hundred of records but both have the sequence id column in common....the column in the second table conatins sequence id missed while loading in the first table, but still there may be some entries missing from second table too...so i need to compare these two columns in both tables to figure out what sequence nos are missing from both tables.....
Re: Compare sequences in two tables to find missing sequence no [message #190220 is a reply to message #190213] Tue, 29 August 2006 15:21 Go to previous messageGo to next message
ebrian
Messages: 2794
Registered: April 2006
Senior Member
You could select from one table and MINUS the results from the other table:
select seq_id "Seqid's in tab1 ONLY" from tab1
MINUS
select seq_id from tab2;

then run the opposite to find records in tab2 that aren't in tab1:
select seq_id "Seqid's in tab2 ONLY" from tab2
MINUS
select seq_id from tab1;
Re: Compare sequences in two tables to find missing sequence no [message #190221 is a reply to message #190220] Tue, 29 August 2006 15:23 Go to previous messageGo to next message
joy_division
Messages: 4643
Registered: February 2005
Location: East Coast USA
Senior Member
Brian:

I think you misread the question the same way I did.

In any event, I don't know why the OP answered with "its already two existing tables..." instead of doing what you asked and posted some create table and insert statements.
Re: Compare sequences in two tables to find missing sequence no [message #190232 is a reply to message #190221] Tue, 29 August 2006 17:13 Go to previous message
ebrian
Messages: 2794
Registered: April 2006
Senior Member
I agree...the CREATE and INSERT statements help to read between the lines.
Previous Topic: Compare sequences in two tables to find missing sequence no
Next Topic: " put_line " Sisters :-)
Goto Forum:
  


Current Time: Fri Dec 09 11:25:00 CST 2016

Total time taken to generate the page: 0.16615 seconds