关于用sql找出重复记录的问题

intel0001 2003-03-13 09:25:26
对一张表table搜索重复的A字段,用 select A from table得出的总共记录数为1056,
再用 select distinct A from table 得出的总共记录数为1055,可知table中有两条记录A是重复的,可是如何用sql找出这两条重复的记录呢?
...全文
176 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
intel0001 2003-03-13
  • 打赏
  • 举报
回复
感谢大家.
beckhambobo(beckham)的方法最好,一步就求出来了,简单明了.
bzszp(SongZip)的sql应该改为
select * from(select count(1) cc ,a.a from a group by a.a) b where b.cc>1;
似乎不太简洁.
supershb(phenix) 的sql我不太理解.

sunnygc 2003-03-13
  • 打赏
  • 举报
回复
select a from table group by a having count(1)>1;
llm06 2003-03-13
  • 打赏
  • 举报
回复
select * from table group by a having count(a)>1
beckhambobo 2003-03-13
  • 打赏
  • 举报
回复
sorry,
select a from table group by a having count(1)>1;
bzszp 2003-03-13
  • 打赏
  • 举报
回复
select * from(select count(1) cc ,a.a from a group by a) b where b.cc>1;
beckhambobo 2003-03-13
  • 打赏
  • 举报
回复
select a from table group by a having count(1)=1;
supershb 2003-03-13
  • 打赏
  • 举报
回复
select * from table
where exists(selet * from table t
where t.pk1 = table.pk1
and t.pk2 = table.pk2
...
and t.pkn = table.pkn)
--pk-->primary key

17,082

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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