查询表中某列相同的记录选出来?

JerryOne 2004-04-28 12:00:37
表T1(A varchar(20),B varchar(40))
(1,F1)
(1,F11)
(1,F111)
(2,F2)
(2,F22)
(3,F3)
(4,F4)

变成
(1,F1)
(1,F11)
(1,F111)
(2,F2)
(2,F22)
请问怎么实现?
...全文
122 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
jinsfree 2004-04-28
  • 打赏
  • 举报
回复
select * from tb where a in(select a from tb group by a having(count(a)>1))
gechaosa 2004-04-28
  • 打赏
  • 举报
回复
select * from t1 where a in (select a from t1
group by A having count(A)>=2)

internetcsdn 2004-04-28
  • 打赏
  • 举报
回复
参照:: jjg0020(jjg0020)

create table t1 (a varchar(10),b varchar(10))
insert t1
select '10','100'
union all select '10','200'
union all select '20','300'
union all select '20','400'
union all select '30','500'

select * from t1 where a in(select a from t1
group by A having count(A)>=2)


jjg0020 2004-04-28
  • 打赏
  • 举报
回复
select * from table
group by A having count(A)>=2

internetcsdn 2004-04-28
  • 打赏
  • 举报
回复
create table t1 (a varchar(10),b varchar(10))
insert t1
select '10','100'
union all select '10','200'
union all select '20','300'
union all select '20','400'
union all select '30','500'

select * from t1 where a in(
select a from(
select a,count(a) as cou from t1
group by a)aa
where cou>=2)
internetcsdn 2004-04-28
  • 打赏
  • 举报
回复
看错
internetcsdn 2004-04-28
  • 打赏
  • 举报
回复
select distinct * from 表

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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