zoukankan      html  css  js  c++  java
  • hive表格取差集

    hive 求两个集合的差集

    业务场景是这样的,这里由两个hive表格A和B

    A的形式大概是这样的:uid
    B的形式大概是这样的:uid

    我想要得到存在A中但是不存在B中的uid

    具体代码如下

    select a.uid from 
    (select uid from tmp_zidali_500wan_fullinfo_new)a
    left outer join
    (select uid from temp_zidali_uid_num_maxvalue_rate)b
    on a.uid=b.uid
    where b.uid is null
    

    在这里我要穿插一个非常重要的知识点,在A和Bjoin(不管是哪种join),在对结果表格取数据的时候,我们不能对结果表格进行一个()c这样的操作。
    错误代码如下

    select a.uid from (
    (select uid from tmp_zidali_500wan_fullinfo_new)a
    left outer join
    (select uid from temp_zidali_uid_num_maxvalue_rate)b
    on a.uid=b.uid
    where b.uid is null
    )c #这是错误的,不能这么做,为了这个错误,搞了三个小时去找这个错误代码
    
  • 相关阅读:
    [CF598E] Chocolate Bar
    [CF629D] Babaei and Birthday Cake
    [CF961D] Pair Of Lines
    [CF468B] Two Sets
    [CF767C] Garland
    [CF864E] Fire
    [CF578C] Weakness and Poorness
    [CF555B] Case of Fugitive
    [CF118E] Bertown roads
    [CF1301D] Time to Run
  • 原文地址:https://www.cnblogs.com/lzida9223/p/10536260.html
Copyright © 2011-2022 走看看