Wrong Results from Query Rewrite
Oracle 10.2.0.4 on Solaris 9
We have noticed wrong results occuring during query rewrite involving table 1 and table 2. Each of these tables have a MV. This problem is noticed only when a sub query is employed for the IN operator. Here is sample query:
Query 1 -
SQL>SELECT COUNT(1) FROM tab1
WHERE END_EFF_DATE=TO_DATE('31-DEC-9999','DD-MON-YYYY')
AND RECIP_ID IN (SELECT RECIP_ID FROM tab2
WHERE END_EFF_DATE=TO_DATE('31-DEC-9999','DD-MON-YYYY')
AND RELATIONSHIP_IND IN ('04','05')
);
COUNT(1)
----------
3015026
The result is different (and correct) when the distinct is used in the sub query as below -