create table sales(
empid varchar(20), --雇员ID
depid number, --部门ID
area varchar(20), --区域
salenum number)--销售额
insert into sales(EMPID,DEPID,AREA,SALENUM) values('ZHANGSAN','1','ASIA',500);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('ZHANGSAN','2','ASIA',500);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('ZHANGSAN','1','ASIA',500);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('ZHANGSAN','1','ASIA',500);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('ZHANGSAN','1','EUR',800);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('ZHANGSAN',null,'EUR',null);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('ZHANGSAN',null,'EUR',null);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('ZHANGSAN',null,'EUR',800);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('ZHANGSAN',null,'EUR',800);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('ZHANGSAN','1','EUR',null);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('ZHANGSAN','1','EUR',null);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('LISI','1','EUR',800);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('LISI','1','EUR',800);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('LISI','2','EUR',1000);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('LISI','2','EUR',1000);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('LISI','2','EUR',800);
insert into sales(EMPID,DEPID,AREA,SALENUM) values('LISI','2','EUR',800);
delete from sales a where (a.DEPID,a.SALENUM) in(select depid,salenum from sales group by depid,salenum having count(*)>1)
and rowid not in(select min(rowid) from sales group by depid,salenum having count(*)>1)
用上面这条语句过滤的话,有NULL值的记录都还在,求正确的写法,谢谢!