示例 -
SELECT date, name,
(SELECT value
FROM this_table
WHERE col1= 'test1' and col2='test'
) AS num_sloths_bought_before
FROM source_table;
当我在redshift中执行查询时,我收到此错误 -
[Amazon](500310) Invalid operation: This type of correlated subquery pattern is not supported yet;
答案 0 :(得分:1)
您通常可以使用连接重写相关标量子查询,对于您的查询,它是左连接:
SELECT date, name, dt.value AS num_sloths_bought_before
FROM source_table
LEFT JOIN
( SELECT val,
value
FROM this_table
WHERE col2='test'
) this_table
ON source_table.val= this_table.val;