accident表不重复的:
select section,seqno from accident group by section,seqno having count(1) = 1human表不重复的:
select section,seqno from human group by section,seqno having count(1) = 1如果是查重复的就只要把having count(1) = 1改成having count(1) > 1 就好了
select section,seqno from accident group by section,seqno having count(1) = 1human表不重复的:
select section,seqno from human group by section,seqno having count(1) = 1如果是查重复的就只要把having count(1) = 1改成having count(1) > 1 就好了
解决方案 »
- 一个关于java程序调用存储过程传数组参数的问题
- SQL抽出数据问题
- 请问ORACLE中,system,sys,root,sysdba,这4种用户的默认密码是什么,如果忘记了如何找到他们,我现在就忘记了,可我都不知道怎么找到。谢
- 哪位用过Analytic Workspace Management?有个问题
- 各位我想實現如下功能,即在一個表的TRIGGER中改動自己的記錄,SQL SERVER是可以的,可是ORACLE不行,報ORA-04091的錯,請問該如何解決???
- oracle 8.1.5 中如何得到9i中case这样的效果呢?急急急急急急急急急急急
- 弱弱的问在SQL*plus中可否一下子创建多张表?
- Oracle中图象问题(解决者200分)
- execute immediate 长sql语句 出错,急
- 有人知道尚观吗?这个机构怎么样呢?
- 刚刚学ORACLE好多东懂,多多指教,关于杀进程的
- 求一个查询的写法,帮顶有份!
select section,seqno,sno from human group by section,seqno,sno having count(1) = 1
1、对于accident表,select distinct section,seqno from accident能不能实现你说的效果?
2、我是想查不重复的记录的“条数”,不知道改怎么查
此句查询的是accident表中section,seqno 组合去除重复后的结果集,就是如果section,seqno 的组合有重复的,那么在查询出来的结果集中只会显示一次。如:
section seqno
---- ---
A B
A C
A C
A D那么查询的结果将会是:
section seqno
---- ---
A B
A C
A D
( select section,seqno
from accident
group by section,seqno
having count(1) = 1
) A; select count(1) from
( select section,seqno,sno
from human
group by section,seqno,sno
having count(1) = 1
) A;
如果我导出现在有重复数据的数据为文本文件,再删除里面的数据,应该就可以加上c2的主键了吧,加上之后再导入,是不是重复的数据就被删除了(重复的数据只剩下一条记录)。
select count(*)
from accident
group by section , seqno
having count(*) =1
如果我导出现在有重复数据的数据为文本文件,再删除里面的数据,应该就可以加上c2的主键了吧,加上之后再导入,是不是重复的数据就被删除了(重复的数据只剩下一条记录)。
====================================
可以的,但如果你并不需要手工决定重复的数据中需要保留哪条数据的话,可以有更简单的方法删除重复的数据:
Delete from human
where rowid not in (select max(rowid) //保留rowid最大的
from human
group by section,seqno,sno
having count(1) > 1
)
and rowid in
(select A.rowid
from human A join (select section,seqno,sno
from human
group by section,seqno,sno
having count(1) > 1
) B
on A.section=B.section and A.seqno=B.seqno and A.son=B.sno
)