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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM