【发布时间】:2022-02-23 03:18:55
【问题描述】:
我有 2 个表,这 2 个表具有 2 列的连接值。 例如,
column1| column2| concatenate value
A B AB
现在,当我计算第 2 个表时,第 2 个表(新创建的表)上的值似乎比原始表更有价值。我该怎么做才能找出哪个值是额外的?
我试过了,但代码不起作用:
SELECT concat (fullVisitorId, cast(visitId as string)) as fullvisitor_visitId_tableA
FROM `ga_sessions_*`
where _table_suffix between '20220101' and '20220130'
UNION all
SELECT concat (fullVisitorId, cast(visitId as string)) as fullvisitor_visitId_tableB
FROM `test_ps_ga360_total_3`
EXCEPT
SELECT concat (fullVisitorId, cast(visitId as string)) as fullvisitor_visitId_tableA
FROM `ga_sessions_*`
where _table_suffix between '20220101' and '20220130'
INTERSECT
SELECT concat (fullVisitorId, cast(visitId as string)) as fullvisitor_visitId_tableB
FROM `test_ps_ga360_total_3`;
任何见解都将不胜感激。
【问题讨论】:
-
您是否只是在 tableB 中寻找不在 TableA 中的行(它们是重复的还是完全不同的)?还是 TableA 中的行不在 TableB 中?
-
x和xy的 CONCAT 是否与xx和y的 CONCAT 相同? (为什么要比较串联而不是源列?) -
能否在您的问题中添加更多详细信息?请添加表1和表2的一些示例行,您正在运行的查询和错误的输出,以及您想要实现的输出。这种行为可能是因为它本身的数据性质,请添加数据样本。
-
大家好,我找到了答案。我稍后会在我有空时将其发布在此帖子上。非常感谢。
标签: sql google-bigquery