我想显示一个数据集中不在另一个数据集中的记录。
这是更大数据集的代码:
select distinct facil_identifier, facil_addr_line1,
trim(facil_city) as facil_city, facil_zip
from xx.tb1 f
where facil_identifier is not null
我想在第一个(较大的)数据集中找到不在较小数据集中的记录。
这是较小数据集的代码:
select distinct facil_identifier, facil_addr_line1,
facil_zip
from xx.tb1 f
where facil_identifier is not null
这是我的尝试:
select distinct facil_identifier, facil_addr_line1,
facil_zip
from xx.tb1 f
where facil_identifier is not null
and facil_identifier not in
(select facil_identifier
from
(select distinct facil_identifier, facil_addr_line1,
trim(facil_city) as facil_city, facil_zip
from xx.tb1 f2
where facil_identifier is not null) as city
where city.facil_identifier = f.facil_identifier)
order by facil_addr_line1
此代码具有巨大的成本。每组少于 3000 条记录。