【发布时间】:2018-04-16 04:31:15
【问题描述】:
我想在 Tableau 上连接两个表。我不想丢失任何条目,所以我使用完整的外部联接:
数据是这样的
表 1:
Name1 Status Storage Certificate
gbo001 Running 16GB on
gbo003 Running 16GB on
gbo005 Running 16GB on
gbo006 Running 16GB on
表2
Name2 Price
gbo001 10000
gbo002 12000
gbo003 12000
gbo004 16000
gbo006 11000
gbo007 14000
所以我使用的是完全外连接,这是我的查询:
SELECT "Table_1"."name1" AS "name1",
"Table_1"."Status" AS "Status",
"Table_1"."Storage" AS "Storage",
"Table_1"."Certificate" AS "Certificate",
"Table_2"."Name2" AS "Name2",
"Table_2"."Price" AS "Price",
FROM "public"."Table1" "Table1"
FULL JOIN "public"."Table2" "Table2" ON ("Table1"."Name1" = "Table2"."Name2")
奇怪的是,它给了我与左连接相同的结果:
Name1 Status Storage Certificate Name2 Price
gbo001 Running 16GB on gbo001 10000
gbo003 Running 16GB on gbo001 12000
gbo005 Running 16GB on null null
gbo006 Running 16GB on gbo006 11000
这些是我期望的完全外部连接的结果:
Name1 Status Storage Certificate Name2 Price
gbo001 Running 16GB on gbo001 10000
null null null null gbo002 12000
gbo003 Running 16GB on gbo003 12000
null null null null gbo004 16000
gbo005 Running 16GB on null null
gbo006 Running 16GB on gbo006 11000
null null null null gbo007 14000
是否可以相应地调整我的查询,以便我可以查看两个表中的所有现有条目?
【问题讨论】:
-
我的表来自 Amazon Redshift。
-
这个查询对我来说是正确的。也许是 Redshift 中的一个错误。这真的是您的完整查询吗?您是否向我们隐藏了
where子句? -
是的,这是一个完整的查询,在这种情况下没有 where 子句。
-
你是如何加入 tableau 中的表的。是否可以不使用自定义 SQL 并使用内置连接?
-
准确地说,我使用的是内置连接。这是它转换为自定义 SQL 查询。已经发现了两个表名字重复的问题(数据集真的很大),所以首先需要在Redshift上做一些改动。嗯,我想是这个问题。
标签: amazon-redshift tableau-api full-outer-join