语句: delete from table1 where id not in (select minid from (select min(id) as minid from table1 group by field1) b); 翻译成中文就是: 删除,“table1”中,id 不在此范围的所有记录.此范围是,筛选出,以field1分组的,所有组别中id的最小的一个. 更直接点就是,以field1分组,选出分组中id最小的一条记录,然后剩下的全部删除. 理解不正确的话,请指点一二.…
1.查询表中重复数据.select * from peoplewhere peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)2.删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录delete from people where peopleId in (select peopleId…
/* ROWID是行ID,通过它一定可以定位到r任意一行的数据记录 ROWID DNAME DEPTNO LOC ------------------ ---------------------------- ---------- ---------- AAASSUAAEAAAAIbAAA ACCOUNTING 10 NEW YORK AAASSUAAEAAAAIbAAB RESEARCH 20 DALLAS AAASSUAAEAAAAIbAAC SALES 30 CHICAGO AAASSUA…
介绍 晚上无聊的时候,我做了一个測试题,測试题的大体意思是:删除Map中Value反复的记录,而且仅仅保留Key最小的那条记录. 比如: I have a map with duplicate values: ("A", "1"); ("B", "2"); ("C", "2"); ("D", "3"); ("…
create table test1( id number, name varchar2(20) ); ,'jack'); ,'jack'); ,'peter'); ,'red'); insert into test1 values(5,'green'); insert into test1 values(6,'green'); 一 查询表中重复数据 1. 使用exists select a.* from test1 a where exists ( select name from ( se…