oracle中怎么去掉某个字段重复数据库 假如表 tb 有 id,name 两列,想去掉name中重复的,保留id最大的数据。delete from tb awhere id not in(select max(id)from tb b where b.name=a.name)若不是这个意思,那么说明的你意图。
oracle 查询两个字段的值重复的记录 select*from tb where rec_id inselect min(rec_id)from tbgroup by code,psamidhaving count(*)>;1)
oracle 删除两个字段重复记录 为了解答你的问题,我专门建了个表测试了一下,终于OK了;你需要先建立一个函数,用于组合数据:create or replace function newsort(a in integer,b in integer,c in integer,d in integer)return varchar2 isres varchar2(32);tmp integer;fir varchar2(32);sec varchar2(32);type type_arr is varray(4)of integer;var type_arr:=type_arr(a,b,c,d);beginres:='';add 2013年6月21日 09:14:57fir:=a|'_'|b;sec:=c|'_'|d;if fir>;sec thenres:=fir;fir:=sec;sec:=res;end if;end addfor i in 1.var.count loopfor j in 1.var.count-1 loopif var(i)>;var(j)thentmp:=var(i);var(i):=var(j);var(j):=tmp;end if;end loop;end loop;for i in 1.var.count loopres:=res|var(i)|'_';end loop;res:=fir|'_'|sec;return(res);end newsort;然后再来查询或删除:(假设你的表名是test)delete from test a where a.rowid>;(select min(b.rowid)from test b where newsort(b.aport,b.actp,b.zport,b.zctp)=newsort(a.aport,a.actp,a.zport,a.zctp));commit;应该是没问题的。(如果你的字段不是integer的,可以自己改改函数)