查找表中某几个字段重复的记录
select rowid,ledger_id,bid from fb_ledgers t1 where t1.rowid!=(select max(rowid) from fb_ledgers t2 where t1.bid=t2.bid and t1.ledger_type=t2.ledger_type and t1.act_date=t2.act_date and t1.dir_flag=t2.dir_flag);
本文提供了一个SQL查询示例,用于从数据库表中找出某些字段组合重复的记录。通过比较每条记录与表中其他记录的特定字段值来实现,确保只保留每个重复组中的最新一条记录。
查找表中某几个字段重复的记录
select rowid,ledger_id,bid from fb_ledgers t1 where t1.rowid!=(select max(rowid) from fb_ledgers t2 where t1.bid=t2.bid and t1.ledger_type=t2.ledger_type and t1.act_date=t2.act_date and t1.dir_flag=t2.dir_flag);
3912

被折叠的 条评论
为什么被折叠?