Question:

- Table1.col1 contains some Names and Table2.col2 is a datetime field.
- Table 3 has both the two columns.
- I’m using Oracle database.
- Table3 is the master table which has more than a billion records.
- Table1 and Table2 has no relation/link.
Expected output from above image:
I need a query to fetch all those pairs of table1.column1 and table.column2 which are not present in Table3 against the respective columns Col1 and Col2. Any Logic or an approach will be helpful.
Edit – The question is complete in itself because it’s only looking for a logic or a pseudocode from the provided data.
Answer:
A reproducible example would help.My guess from your description is that you want to create a Cartesian product of
table1
and table2
and minus
table3
from that Cartesian productselect t3.column1, t3.column2
from table3 t3
minus
select t1.column1, t2.column2
from table1 t1
cross join table2 t2
If that is not what you are looking for, providing the reproducible example would be quite helpful.If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com
Leave a Review