hive left join 问题

select
    apply.*,
    label.*
from
    apply_month apply
left join 
    overdue_label label
on apply.transactionid = label.transid
where
    apply.stat_month=${month}
    and label.applymonth=${month}
;


select
    apply.*,
    label.*
from
    apply_month apply
left join
    ( 
    select 
        * 
    from 
        overdue_label
    where 
        applymonth=${month}
    ) label
on apply.transactionid = label.transid
where
    apply.stat_month=${month}
;

第一个sql执行的结果行数少于第二个sql的执行结果。
原因是第一个sql where包含左表条件和右表条件,而第二个sql where只包含左表的条件。

posted @ 2020-10-16 17:33  机器狗mo  阅读(680)  评论(0编辑  收藏  举报