首页 > 数据库技术 > 详细

SQL Server查询重复数据

时间:2019-03-07 19:03:12      阅读:147      评论:0      收藏:0      [点我收藏+]

1.查询单列重复:

 select * from test
 where name in (select name from test group by name having count
 (name) > 1)

2.查询多列重复:

SELECT a.* FROM test a,(
SELECT name,code
FROM test 
GROUP BY name,code
HAVING COUNT(1)>1

) AS b
WHERE a.name=b.name AND a.code=b.code

  

SQL Server查询重复数据

原文:https://www.cnblogs.com/Nigel/p/10491370.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!