表tt
序号 aa bb cc dd
1 11111 3333 3333 345
2 22222 4444 6666 123
3 33333 4444 6666 231
4 44444 4444 3333 111
5 55555 4444 7777 222现在想把同时满足bb列、cc列中同时重复的数据提取出来
就是说我想要序号为:2、3的这两条数据,sql语句怎么写啊?
序号 aa bb cc dd
1 11111 3333 3333 345
2 22222 4444 6666 123
3 33333 4444 6666 231
4 44444 4444 3333 111
5 55555 4444 7777 222现在想把同时满足bb列、cc列中同时重复的数据提取出来
就是说我想要序号为:2、3的这两条数据,sql语句怎么写啊?
select * from ttwhere bb in(select bb from tt group by bbhaving count(id)>1) and cc in(select cc from tt group by cc having count(id)>1)
(select tx.c,tx.aa,tx.bb from (select COUNT(*) c,t.aa,t.bb from temp t
group by t.aa,t.bb) tx where tx.c > 1) ttt
left join temp tpp on ttt.aa=tpp.aa and ttt.bb=tpp.bb
inner join
(select bb,cc from tt group by bb,cc having count(*)>1) b
on a.bb=b.bb and a.cc=b.cc这个语句可以啊,谢谢这位朋友