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只包含左表的条件。

原文地址:https://www.cnblogs.com/sandy-t/p/13827678.html