postgersql去重
有重复的数据但是id不同
//查询
select ctid, * from table where ctid in
(select min(ctid) from table
where
columnA = 'A' AND columnB = 'B'
group by columnC having count(*) > 1);
//删除
delete from table where ctid in
(select min(ctid) from table
where
columnA = 'A' AND columnB = 'B'
group by columnC having count(*) > 1);
相同数据只显示最后更新的一条数据
//查询
select
*
from
table t
where
update_date=(select max(update_date) from
tableA where
columnA=t.columnA and columnB=t.columnB );