=======
(select cust_num, favourite_colour from table1
minus
select cust_num, favourite_colour from table2)
union all
(select cust_num, favourite_colour from table2
minus
select cust_num, favourite_colour from table1);
========
The above SQL is to run slow.
There will 2 full table scans on table1 and another 2 full table scans on table2. Isn't it bad?
This above SQL was modified by Tom and another brilliant Italian (I forgot his name). Their version is given below:
TamilPHP Code:select c1, c2, c3, count(src1), count(src2)
from
(
select a.*, 1 SRC1, to_number(null) SRC2
from a
union all
select b.* , to_number(null) SRC1, 2 SRC2
from b
)
group by c1, c2, c3
having count(src1) <> count(src2)
/




Reply With Quote