大数据大数据,机器学习,人工智能Hive在简书

Hive 差集交集并集

2019-04-30  本文已影响0人  苏啦啦哇咔咔

1. 交集:

select id from t1 join select id from t2

2. 并集

select id from t1 union select id from t2

select id from t1 union all select id from t2

select id from t1 intersect select id from t2

3. 差集

select a.id from t1 left join t2 on t2.id = t1.id and t2.id is null

select id from t1 except select id from t2

上一篇下一篇

猜你喜欢

热点阅读