在线等
解决方案 »
- 新建了个插入触发器,在插入的时候出现“通信通道的文件结束”错误
- oracle中怎样查询函数f在哪被调用了
- 请教一个数据集成平台实时数据的导入导出问题
- oracle语法求助
- 关于ORACLE 10G创建用户,表空间的问题
- 数据库的日期格式查询出来能不能改变啊??
- oracle 端口问题 救命
- 帮偶写个语句,xie
- enterprise manager console(OEM)的linux配置问题!特急!100分相送!!
- ArcSDE for Oracle11g安装问题
- 如何获得小时数(星期天除外) 难!难!
- 用oci 怎么执行alter system kill session 'sid,serial#'?
如果只保留最后一条,那么执行:
delete
from yourtable A
where exists (Select '1' from yourtable B
where A.ID = B.ID
and A.ROWID < B.ROWID);
如果只保留第一条,那么执行:
delete
from yourtable A
where exists (Select '1' from yourtable B
where A.ID = B.ID
and A.ROWID > B.ROWID);ps:记得commit;ps2:没有分...没有下次了。
比如TABLE里的字段FIELD01 = '01'
select * from TABLE A WHERE A.FIELD01 = '01' AND ROWNUM = 1
table a 记录如下:
id mobile name
1 12 3
2 12 4
3 13 5
我要显示的结果是
id mobile name
1 12 3
3 13 5
SELECT MAX(A.id) A.mobile MAX(A.name) FROM TABLE A GROUP BY A.mobile
有要求的话要根据具体要求来写,可能要复杂些。
id mobile name
1 12 3
2 12 4
3 13 5
我要显示的结果是
id mobile name
1 12 3
3 13 5
用ORACLE 分析函数row_number():select t.id,t.mobile,t.name from (select id,mobile,name,row_number() over(partition by mobile odrer by name) row_num from a) t
where row_num=1;
可以根据你具体的需求做下变动即可