Hello,
I know you can run a subquery in SQL Server to see if a list from one table matches all that of a list from another table, but when I run this in Oracle, it seems to work only some of the time. For example, please note this query:
select * from csq_admin_lookup
where adm_lu_system = 'CCP'
and adm_lu_type = 'CDIV'
and adm_lu_description in (
select distinct cust_division
from csq_customers)
This query returns 92 records. Then when I try to pull everything from the admin table, I get 106 records:
select * from csq_admin_lookup
where adm_lu_system = 'CCP'
and adm_lu_type = 'CDIV'
Logic has it that the following query would return 14 results, because the results of the previous queries imply that there are 14 records in the admin table that do not exist in the customer table (notice the word NOT):
select * from csq_admin_lookup
where adm_lu_system = 'CCP'
and adm_lu_type = 'CDIV'
and adm_lu_description NOT in (
select distinct cust_division
from csq_customers)
But this last query returns 0 records, implying that all records in the admin table are found in the customer table, which contradicts what the previous 2 queries imply.
Does Oracle support this type of subquery, where you can compare two list of string data? How about comparing IDs?
Thanks,![[smile] [smile] [smile]](/data/assets/smilies/smile.gif)
Peter
I know you can run a subquery in SQL Server to see if a list from one table matches all that of a list from another table, but when I run this in Oracle, it seems to work only some of the time. For example, please note this query:
select * from csq_admin_lookup
where adm_lu_system = 'CCP'
and adm_lu_type = 'CDIV'
and adm_lu_description in (
select distinct cust_division
from csq_customers)
This query returns 92 records. Then when I try to pull everything from the admin table, I get 106 records:
select * from csq_admin_lookup
where adm_lu_system = 'CCP'
and adm_lu_type = 'CDIV'
Logic has it that the following query would return 14 results, because the results of the previous queries imply that there are 14 records in the admin table that do not exist in the customer table (notice the word NOT):
select * from csq_admin_lookup
where adm_lu_system = 'CCP'
and adm_lu_type = 'CDIV'
and adm_lu_description NOT in (
select distinct cust_division
from csq_customers)
But this last query returns 0 records, implying that all records in the admin table are found in the customer table, which contradicts what the previous 2 queries imply.
Does Oracle support this type of subquery, where you can compare two list of string data? How about comparing IDs?
Thanks,
![[smile] [smile] [smile]](/data/assets/smilies/smile.gif)
Peter