如图所示,左面为原表,右边为希望查询到的结果,查找所有重复值大于1的记录并显示出来,两列同时重复
序号 a b
1 1 3
2 1 3
3 2 4
4 3 4
5 4 5
6 5 6
7 5 6
希望得到的结果
序号 a b
1 1 3
2 1 3
6 5 6
7 5 6
select id,value from table where value in (select value from table group by value having count(1)>1)
select a.* from TAB a
where exists (select VALUE_C from TAB where VALUE_C=a.VALUE_C group by VALUE_C having count(VALUE_C)>=2 )