易截截图软件、单文件、免安装、纯绿色、仅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 / 非技术区

假设table01 中有 以下资料
emp_no emp_name
------- ------------
0001 TOM
0002 JOHN
0003 MARY
常用电话 
而我们要得到以下的OUTPUT (或是各种其他的output)
0001,TOM
0002,JOHN ......

Oracle临时表使用问题 - Oracle / 开发

我的处理是这样的:
我有一个很大的数据集合,处于性能方面的考虑需要使用临时表过渡,并且使用分页的方式向临时表中插入数据,数据使用完毕后,删除临时表的数据。
出现的现象:当Oracle重新启动后,第一页插入的 ......

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号