为什么要用循环语句,你只是要显示有重复的信息,用下面类似的语句不行? select * from test_table t1 where exists(select 1 from test_table t2 where t1.id=t2.id group by t2.id having count(*)>1)
select * from table t1 where sum(case when (select 1 from table t2 where t1.id=t2.id) is not null then 1 else 0 end)=13
select * from test_table t1 where exists(select 1 from test_table t2 where t1.id=t2.id group by t2.id having count(*)=13) 这样也不行?
Select * from t a where exists(select 1 from ( select c.aa from t group by t.aa having sum(1)=13) b where a.aa=b.aa)
select *
from test_table t1
where exists(select 1
from test_table t2
where t1.id=t2.id
group by t2.id
having count(*)>1)
else
0
end)=13
from test_table t1
where exists(select 1
from test_table t2
where t1.id=t2.id
group by t2.id
having count(*)=13)
这样也不行?
select c.aa from t group by t.aa having sum(1)=13) b
where a.aa=b.aa)