Oracle Minus 关键字
SQL中的MINUS关键字
SQL中有一个MINUS关键字,它运用在两个SQL语句上,简单来说,就是找到第一个SQL语句的结果中有且
第二个SQL语句结果中没有的记录,其语法如下:
[SQL Segment 1]
MINUS
[SQL Segment 2]
删除完全重复记录
delete from sendbill_header where rowid in
(select rowid from sendbill_header
minus
select max(rowid) from sendbill_header
group by no,filename);
delete from sendbill_lines where rowid in
(select rowid from sendbill_lines
minus
select max(rowid) from sendbill_lines
group by headerno,mtlno,version,qty);
可以体会下minus的作用,对比union
create table A(
a number
);
create table B(
b number
);
insert into a values(1);
insert into a values(2);
insert into a values(3);
insert into a values(4);
insert into a values(5);
insert into b valu