在Oracle中查询得到类似这样的结果: a b ab 1 2 1,2 2 1 2,1 如何去掉其中任意一条记录select * from table1 t where not exists( select 1 from table1 where a=t.b and b=t.a and a>t.a) SQL code: with temp as( select 1 a,2 b,'1,2' ab from dual union all select 2 a,1 b,'2,1' ab from dual ) select * from temp where a = (round(dbms_random.value)+1)
引用一下狂浪的,改一下: delete from table1 t where exists( select 1 from tmp where a=t.b and b=t.a and a<t.a) and rownum=1 加个这个 就选出一条了,
楼主的描述跟问题严重不符合啊!
根据问题描述,去掉任意一行的话,delete from tb where rownum=1; 就好了。
至于重复行记录去掉的,要看有几个字段,才好写sql语句,加入你表tb 有id主键、c1、c2、c3。那么重复的记录就是c1、c2、c3字段重复吧。 那么删除重复行的sql就是 delete from tb t2 where exists(select 1 from tb t1 where t1.c1=t2.c1 and t1.c2=t2.c2 and t1.c3=t2.c3 and t1.id<>t2
下个Oracle for vista 版本的安装试试 10G和11G的 http://www.oracle.com/technology/software/products/database/index.html ------------------------------------------- ......