--查询初始化数据
select ctid, * from m_gwd_sj2;
--查询重复数据数
select distinct rid, count(*) from m_gwd_sj2 group by rid having count(*) > 1;
--查询要保留的数据
select ctid, * from m_gwd_sj2 where ctid in (select min(ctid) from m_gwd_sj2 group by rid);
--删除重复数据
delete from m_gwd_sj2 where ctid not in (select min(ctid) from m_gwd_sj2 group by rid);
--查看最后结果
select ctid, * from m_gwd_sj2;
--其他方法(在数据量较大的情况下用下面的方法,效率更高)
delete from m_gwd_sj2 a where a.ctid <> (select min(b.ctid) from m_gwd_sj2 b where a.rid = b.rid);