不去重狀態
select a.*,b.recon_amt
from free_settlement_first aleft join free_settlement_second b on a.settlement_first_id = b.settlement_first_id
有2條數據出現了重復
使用子查詢去重
select a.*,b.recon_amt
from free_settlement_first aleft join free_settlement_second b on a.settlement_first_id = b.settlement_first_id
where not exists(select 1from free_settlement_second b2where a.settlement_first_id = b2.settlement_first_idand b.settlement_second_id > b2.settlement_second_id)