Java教程

sql删除重复记录

本文主要是介绍sql删除重复记录,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

select * from tab_name where id in (
select min(id) from tab_name group by meter_id,Cjq_time having count(*)>1)


delete from tab_name where id in(
select id from (
(select a.id from tab_name a ,
(select meter_id,Cjq_time,min(id) id,count(*) icount from tab_name group by meter_id,Cjq_time having count(*)>1) b
where a.meter_id=b.meter_id and a.cjq_time=b.cjq_time and a.id>b.id )

)c

)

这篇关于sql删除重复记录的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!