欢迎投稿

今日深度:

hive 差集,

hive 差集,


A表

idnameagecity
1a18beijing
2b20beijing
B表

idschoolcity
1mbeijing
3nbeijing
5psichuan

假设两个表的partition是city,现在的需求是求A表中存在而B表中不存在(A-B)的信息,筛选条件是"id"且city='beijing':

    

select A.id from(
        (select * from  A where A.city = 'beijing') T1
        left outer join
        (select * from B where B.city = 'beijing') T2
        on A.id = B.id and B.id is NULL
    )

以上语句最后得到的结果是:“1”。即实现了根据id求两个表的差集。

www.htsjk.Com true http://www.htsjk.com/hive/33916.html NewsArticle hive 差集, A表 id name age city 1 a 18 beijing 2 b 20 beijing B表 id school city 1 m beijing 3 n beijing 5 p sichuan 假设两个表的partition是city,现在的需求是求A表中存在而B表中不存在(A-B)的信息,筛选条件...
相关文章
    暂无相关文章
评论暂时关闭