找同一表中某字段重复的记录?

emosen999 2005-11-28 05:27:30
找出如下表中f1&f2重复的记录

如有一表T1:
f1 f2 f3 f4
11 22 33 44
11 22 333 444
111 222 3333 4444

要得到结果:
f1 f2 f3 f4
11 22 33 44
11 22 333 444

直接一句SQL好像没办法解决?那用存储过程要怎么写?

在线等。。。。。。。。。谢谢
...全文
152 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
浩方软件HFWMS 2005-11-28
  • 打赏
  • 举报
回复
select
*
from
表 A
where
(select count(*) from 表 where F1=A.F1 and F2=A.F2)>1
zlp321002 2005-11-28
  • 打赏
  • 举报
回复
select
*
from
表 A
where
(select count(*) from 表 where F1=A.F1 and F2=A.F2)>1
zhixuan 2005-11-28
  • 打赏
  • 举报
回复
select * from test group by id,num,t having count( *)>1 表为 id,num,t
表结构: id,num,t num是字符,t也是字符,id是数字 .表结构: id,num,t num是字符,t也是字符,id是数字 可以采取这样的逻辑写出符合自己表结构的语句

下面是搜索某写字段值重复的方法,

select * from test where num||'##'||t in (select num||'##'||t from test group by num,t having count(*)>1)

表结构: id,num,t num是字符,t也是字符,id是数字 可以采取这样的逻辑写出符合自己表结构的语句,,注意:'##'在其中的作用,要根据自己表结构的数据来采用不同的符号组合,,

哈哈,--------轩
OracleRoob 2005-11-28
  • 打赏
  • 举报
回复

select a.f1,a.f2,a.f3,a.f4
from T1 a inner join
(select f1,f2 from T1 group by f1,f2 having count(*)>1) b
on a.f1=b.f1 and a.f2=b.f2
emosen999 2005-11-28
  • 打赏
  • 举报
回复
Help,。。。。。。。。。。。

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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