sql server 2005 如何查询并删除同时有2个字段内容重复的数据

2024-12-29 20:21:11
推荐回答(1个)
回答1:

delete from table t1 where exists(
select * from (select 缴费编号,缴费金额,max(缴费时间) as 缴费时间,count(*) as con from table group by 缴费编号,缴费金额 ) t2 where t1.缴费编号=t2.缴费编号 and t1.缴费编号=t2.缴费编号
and t1.缴费时间=t2.缴费时间 and t2.con>1
)