以下是我想要转换为Teradata的Oracle SQL查询。
with Temp As
(
select
A,
B,
C
from table1
UNION
select
D,
E,
F
from table2
)
select * from temp where A<>'XXX'
UNION
select * from temp t1 where A='XXX'
and NOT EXISTS(select 1 from temp t2 where t1.b=t2.b and t1.c=t2.c and t2.A='YYY')