34,593
社区成员
发帖
与我相关
我的任务
分享
SELECT * FROM TB WHERE ID IN (SELECT ID FROM TB GROUP BY TB HAVING COUNT(1)>1)
declare @t table(i int)
insert into @t values(1)
insert into @t values(1)
insert into @t values(7)
insert into @t values(5)
insert into @t values(4)
insert into @t values(7)
insert into @t values(4)
insert into @t values(8)
select t.* from @t t where t.i in(select i from @t group by i having count(*)>1)
/*
i
-----------
1
1
7
4
7
4
*/
select t.* from @t t where t.i in(select i from @t group by i having count(*)>1) order by t.i
/*
i
-----------
1
1
4
4
7
7
*/
select t.* from 表 t where t.i in(select i from 表 group by i having count(*)>1)