数据库
首页 > 数据库> > 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

)

标签:name,删除,sql,meter,tab,time,重复记录,id,select
来源: https://www.cnblogs.com/kkkV/p/14698160.html