insert into z1 select 1,'bn',1 from dual union
select2,'bn',2 from dual union
select2,'bnlj',3 from dual union
select3,'bnlj',4 from dual;
SQL> create table z1(v1 number(4),v2 varchar(10),v3 number(10));
表已创建。
SQL> insert into z1 select 1,'bn',1 from dual union
2select2,'bn',2 from dual union
3select2,'bnlj',3 from dual union
4select3,'bnlj',4 from dual;
已创建4行。
SQL> select * from z1;
V1 V2
V3
---------- ---------- ----------
1 bn
1
2 bn
2
2 bnlj
3
3 bnlj
4
SQL> select * from z1 a where a.v2='bn' and a.v1 not in(select v1 from z1 b where b.v2='bnlj');
V1 V2
V3
---------- ---------- ----------
1 bn
1 |