首页 > 代码库 > HIVE求两个集合的减集

HIVE求两个集合的减集

hive中不支持not in的写法,但是可以通过left outer join来替代

技术分享

写法如下:

select a.* 
from (
select * 
from rpt_pms_continue 
where category_level_flag='末级类目' 
and cart_tracker_id is not null 
and ds='2015-01-08' 
) a 
left outer join (
select * 
from pms.cross_sale_path 
where ds='2015-01-08' 
and rcmd_algorithm_id in (419,420,580,581,582,650,950,1331,1655,1656,1657,1658,1659,1660,1690,1691,1950,1951)
) b on (a.cart_tracker_id=b.cart_track_id) 
where b.cart_track_id is null;

HIVE求两个集合的减集