Where IN 子句在给定子查询时不起作用

问题描述 投票:0回答:1

我有一个问题

select comma_separated_asin from temp.asin_workbench_filtered

给出

COMMA_SEPARATED_ASIN
'B098GJ3K6Z','B08Q26RV4D'

我还有一个问题

select
    distinct asin,
    ordered_revenue,
    report_date
from
    ams_cubes.campaigns_asin_workbench
where asin in
    (select comma_separated_asin from temp.asin_workbench_filtered);

这行不通

但是如果我手动给出像这样的值

where asin in ('B098GJ3K6Z','B08Q26RV4D')

我得到想要的结果

我想知道并理解为什么 where in 子句不接受通过子查询给出的值。

我尝试检查

asin
comma_separated_asin
的数据类型都具有相同的数据类型
VARCHAR(16777216)

我期待数据应该来,因为我不想硬编码 asin 值,因为它是一个动态输入。

subquery snowflake-cloud-data-platform where-clause clause
1个回答
0
投票

如果运行以下查询会发生什么情况?

select
    distinct asin,
    ordered_revenue,
    report_date
from
    ams_cubes .campaigns_asin_workbench
where  contains((select comma_separated_asin from temp .asin_workbench_filtered), asin );
© www.soinside.com 2019 - 2024. All rights reserved.