易截截图软件、单文件、免安装、纯绿色、仅160KB

在Oracle中如何去掉这样的重复行 - Oracle / 高级技术

在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)


引用
select * from table1 t
where not exists(
select 1 from table1 where a=t.b and b=t.a and a>t.a)

引用一下狂浪的,改一下:
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 加个这个
就选出一条了,

引用
在Oracle中查询得到类似这样的结果:
a b ab
1 2 1,2
2 1 2,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 10g web登陆EM的问题? - Oracle / 基础和管理

安装了Oracle 10g,默认安装了orcl数据库,这个数据库能不能删除啊,还有我如果新建了其他数据库,怎么知道在web中登陆不同数据库的地址啊?

1
可以删除
2
在WEB地址栏中输入地址的时候指定新创建的数据库的IP ......

Oracle离线访问---求助 - Oracle / 基础和管理

大家好,我现在把oracle服务器上面的原始文件,下载到本机了.我想在本机访问数据库怎么设置啊.是不是类似可以建立一个什么虚拟服务器来实现.请大家出出主意
引用
    大家好,我现在把oracle服务器上面 ......

Oracle 数据导出问题 - Oracle / 高级技术

exp user/password@dbname file=c:\table.dmp tables=jbitaku,jbitakum grants=y
然後按回車鍵 說明:  user/password@dbname  分別表示用戶名,密碼和服務名 f ......

oracle 10g data guard - Oracle / 基础和管理

做玩data guard 后
在Primary服务器 执行 
SQL>SELECT SEQUENCE#,APPLIED from V$ARCHIVED_LOG ORDER BY SEQUENCE#;
 SEQUENCE# APP
---------- ---
  13 NO
  13 YES ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号