Select * from tbl where a in (select a from tbl group by a having count(a)>1)
Select * from tbl where a in (select a from tbl group by a having count(*)>1)
select a from 表 group by a having count(a)>1
insert into aa SELECT 1 union all SELECT 1 union all SELECT 1 union all SELECT 2 Select * from aa where ID in (select ID from aa group by ID having count(*)>1)(所影响的行数为 4 行) 1 1 1 1 SQL Server 啊 努力 奋斗-----------------------------------------------------
上面的少了Create Create Table aa(id int) insert into aa SELECT 1 union all SELECT 1 union all SELECT 1 union all SELECT 2 Select * from aa where ID in (select ID from aa group by ID having count(*)>1)(所影响的行数为 4 行) 1 1 1 1 SQL Server 啊 努力 奋斗-----------------------------------------------------
(select a from tbl group by a
having count(a)>1)
a
from
表
group by
a
having count(a)>1
SELECT 1 union all
SELECT 1 union all
SELECT 1 union all
SELECT 2
Select * from aa where ID in (select ID from aa group by ID having count(*)>1)(所影响的行数为 4 行)
1
1
1
1 SQL Server 啊 努力 奋斗-----------------------------------------------------
Create Table aa(id int)
insert into aa
SELECT 1 union all
SELECT 1 union all
SELECT 1 union all
SELECT 2
Select * from aa where ID in (select ID from aa group by ID having count(*)>1)(所影响的行数为 4 行)
1
1
1
1 SQL Server 啊 努力 奋斗-----------------------------------------------------