【问题标题】:Perform Union using joins not union ALL使用连接而不是 union ALL 执行联合
【发布时间】:2016-04-18 11:01:57
【问题描述】:

我们有一个要求,在我们尝试使用 informatica 云对 2 个不同数据库的表执行联合操作时,我们没有联合转换。所以尝试探索这是否可以使用左/全外连接来执行?

select * from t join p on t.id = p.id
union
select * from t join p on t.id = p.id2

注意:Not Union ALL only Union

【问题讨论】:

  • 这里 T 来自 teradata,p 来自 oracle,我们尝试将 t 和 p 连接两次。因此,就我们的数据提取而言,发布的查询是正确的

标签: sql join cloud union informatica


【解决方案1】:

unionunion all 之间的区别只是删除了不同的值。您的问题的答案是,您可以使用一堆 coalesce() 语句、select distinctfull join 来模拟 union

但是,为什么不直接做:

select *
from t join
     p
     on t.id in (p.id, p.id2);

根据数据,您可能需要select distinct

select distinct *
from t join
     p
     on t.id in (p.id, p.id2);

【讨论】:

    猜你喜欢
    • 2020-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-23
    • 1970-01-01
    • 2012-03-06
    相关资源
    最近更新 更多