
select
from
(
select
a,b,c,d,count(a)
c
from
F
group
by
a,b,c,d)
tab
where
tabc>1
这样就行了啊,还有重复的记录条数呢
楼下的更好些,select
from
F
group
by
a,b,c,d
having
count()>1
我没想到,呵呵
1、创建测试表,
create table test_count(id varchar2(20), value varchar2(20));
2、插入测试数据
insert into test_count values(1, 1);
insert into test_count values(2, 1);
insert into test_count values(3, 1);
insert into test_count values(4, 2);
insert into test_count values(6, 1);
insert into test_count values(7, 3);
insert into test_count values(8, 3);
insert into test_count values(9, 3);
insert into test_count values(10, 3);
commit;
3、查询表中全量数据,select t, rowid from test_count t;
4、编写sql,可以得到每一个value重复的个数,并按照由大到小排列;
select value, count() from test_count t group by value order by 2 desc
直接查出重复
--查出表中有重复的id的记录,并计算相同id的数量
select id,count(id) from @table group by id having(count(id)>1)
其中,group by id,是按id字段分组查询:
select id,count(id) from @table group by id
可以得到各不同id的数量合计
having(count(id)>1)判断数量大于1,也就是有重复id的记录
以上就是关于SQL 查询相同数据全部的内容,包括:SQL 查询相同数据、sql查询语句计算重复数据个数、sql查找重复多次的数据等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)