17,377
社区成员
发帖
与我相关
我的任务
分享
SQL> select * from a;
ID NAME AA BB
---------- ---- ---------- ----------
1 a1 1 3
2 a1 2 4
3 a2 1 5
4 a3 2 6
8 a3 2 6
5 a4 2 7
6 a5 1 13
7 a5 2 14
8 rows selected
SQL>
SQL> select * from a where name in (
2 select name from a
3 where aa in (1,2)
4 group by name
5 having count(distinct aa) >1)
6 ;
ID NAME AA BB
---------- ---- ---------- ----------
1 a1 1 3
2 a1 2 4
6 a5 1 13
7 a5 2 14