求sql语句

Methodor 2008-07-09 08:05:35
列出所有有重复数据的,举例:
表:tb1
列:col1,col2,col3
列出所有col2数据有重复的行

sql如何写?
...全文
88 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
hyf_0023 2008-08-07
  • 打赏
  • 举报
回复
select col2,count(*) from tb1 group by col2 having count(*)>1;
zhouhan0048 2008-07-09
  • 打赏
  • 举报
回复
select * from emp where name in
(select name from emp group by name having count(*)>1)

也可以
arrow_gx 2008-07-09
  • 打赏
  • 举报
回复
select * from tb1 where col2 in(select col2 from tb1 group by col2 having count(col2)>1)
zhouhan0048 2008-07-09
  • 打赏
  • 举报
回复
select * from emp where
(select count(*) from emp e
where e.name=emp.name) >1
tianyusunkuangyu 2008-07-09
  • 打赏
  • 举报
回复
select * from tb1 where col2 in(select col2 from tb1 group col2 having count(col2)>1)

22,210

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧