阅读量:1
不去重状态
select a.*, b.recon_amt from free_settlement_first a left join free_settlement_second b on a.settlement_first_id = b.settlement_first_id
有2条数据出现了重复
使用子查询去重
select a.*, b.recon_amt from free_settlement_first a left join free_settlement_second b on a.settlement_first_id = b.settlement_first_id where not exists(select 1 from free_settlement_second b2 where a.settlement_first_id = b2.settlement_first_id and b.settlement_second_id > b2.settlement_second_id )