oracle查询/去除重复值

版权声明:本文为个人知识整理,欢迎指正、交流、转载。 https://blog.csdn.net/u014711094/article/details/82632567
-- 查找重复值及最小的id
select	min (id), province, city, count (*) cnt
	from t 
	group by province, city
	having count (*) > 1;

-- 保留最小的重复值
delete from t  
	where id not in (
		select min(id) from t
			group by province, city
);

猜你喜欢

转载自blog.csdn.net/u014711094/article/details/82632567