
sql 查询重复记录 收藏
发布日期:2021-05-13 07:42:00
浏览次数:14
分类:博客文章
本文共 3775 字,大约阅读时间需要 12 分钟。
1 ���������������������������������������������������������������������������peopleId������������ select * from people where peopleId in ( select peopleId from people group by peopleId having count (peopleId) > 1 )
���������
select * from testtable
where numeber in (select number from people group by number having count(number) > 1 )
������������testtable������number��������������� 2 ���������������������������������������������������������������������������peopleId������������������������rowid��������������� delete from people where peopleId in ( select peopleId from people group by peopleId having count (peopleId) > 1 ) and rowid not in ( select min (rowid) from people group by peopleId having count (peopleId ) > 1 ) 3 ������������������������������������������������������ select * from vitae a where (a.peopleId,a.seq) in ( select peopleId,seq from vitae group by peopleId,seq having count ( * ) > 1 ) 4 ������������������������������������������������������������������rowid��������������� delete from vitae a where (a.peopleId,a.seq) in ( select peopleId,seq from vitae group by peopleId,seq having count ( * ) > 1 ) and rowid not in ( select min (rowid) from vitae group by peopleId,seq having count ( * ) > 1 ) 5 ������������������������������������������������������������������rowid��������������� select * from vitae a where (a.peopleId,a.seq) in ( select peopleId,seq from vitae group by peopleId,seq having count ( * ) > 1 ) and rowid not in ( select min (rowid) from vitae group by peopleId,seq having count ( * ) > 1 ) (���) ��������� ���A���������������������������name������ ������������������������������name��������������������������� ���������������������������������������������������������������name��������������������������� Select Name, Count ( * ) From A Group By Name Having Count ( * ) > 1 ���������������������������������������: Select Name,sex, Count ( * ) From A Group By Name,sex Having Count ( * ) > 1 (���) ��������� declare @max integer , @id integer declare cur_rows cursor local for select ���������, count ( * ) from ������ group by ��������� having count ( * ) > ��� 1 open cur_rows fetch cur_rows into @id , @max while @@fetch_status = 0 begin select @max = @max - 1 set rowcount @max delete from ������ where ��������� = @id fetch cur_rows into @id , @max end close cur_rows set rowcount 0 ��������� ���������������������������������������������������������������������������������������������������������������������������������������������������������������Name������������������������������������������������������������������������ 1 ������������������������������������������������������ select distinct * from tableName ��������������������������������������������� ������������������������������������������������������������1������������������������������������ select distinct * into #Tmp from tableName drop table tableName select * into tableName from #Tmp drop table #Tmp ��������������������������������������������������������������������������������������������� 2 ��������������������������������������������������������������������������������������������� ���������������������������Name,Address������������������������������������������������ select identity ( int , 1 , 1 ) as autoID, * into #Tmp from tableName select min (autoID) as autoID into #Tmp2 from #Tmp group by Name,autoID select * from #Tmp where autoID in ( select autoID from #tmp2) ������������select������������Name���Address���������������������������������������autoID���������������������������������select������������������������ (���)
������������ select * from tablename where id in ( select id from tablename group by id having count (id) > 1 )
���������http://www.cnblogs.com/congcong/archive/2008/11/07/1328834.html
������������
发表评论
最新留言
不错!
[***.144.177.141]2025年04月29日 20时52分16秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Scala中的包
2021-05-14
参加阿里的Java面试经验
2021-05-14
Python微信公众号
2021-05-14
2017物联网安全事件盘点
2021-05-14
他来了他来了,他带着云栖大会的免费门票走来了
2021-05-14
Oracle笔记
2021-05-14
JS实现删除行按钮只有一行时不能删除
2021-05-14
有问题找男人帮忙- Linux下man命令
2021-05-14
如何复用外部shell脚本
2021-05-14
VTK:小部件之SeedWidgetWithCustomCallback
2021-05-14
JAVA集合类Collection浅析
2021-05-14
Lambda表达式使用整理总结
2021-05-14
嵌入式软件工程师职业路线
2021-05-14
Fastdfs源码分析4----缓存区设计
2021-05-14
获取linux 主机cpu类型
2021-05-14
限流的算法有哪些?
2021-05-14
Failed to notify build listener.
2021-05-14
TextWiew单个线条
2021-05-14
Android Studio updating indices 一直刷新和闪烁
2021-05-14