17,377
社区成员
发帖
与我相关
我的任务
分享
SQL> select name from taba;
NAME
----------------
A
B
C
D
E
SQL> select name from tabb;
NAME
----------------
E
F
C
D
E
R
X
已选择7行。
SQL> edit
已写入 file afiedt.buf
1 select name from tabb where rowid not in
2 ( select max(rowid) from tabb where name in
3 ( SELECT NAME FROM TABB INTERSECT SELECT NAME FROM TABA )
4 group by name
5 )
6 union
7 ( select name from taba
8 minus
9 select name from tabb
10* )
SQL> /
NAME
----------------
A
B
E
F
R
X
已选择6行。
SQL>
select * from (
select name from tableA
union
select name from tableB
) t
minus
select * from (
select name from tableA
intersect
select name from tableB
) t2
select name from tableA --(结果有5个: A, B, C, D,E)
union
select name from tableB --(结果有7个: E, F, C, D,E, R, X)