Can you please help me how to write a correlated sub query in snowflake?
select a
b,
(select d.x from d inner join b on d.id=b.id) As x,
(select d.x from d inner join bon d.id!=b.id) AS Y
FROM a
inner join b on a.id=b.id
select X from d table based on join condition.select another column from same table based on another join condition The above query almost my original scenario. can you help me how to write a same query in snowflake
SELECTlist you can only have subqueries that return EXACTLY ONE ROW each. I'm guessing that's not the case in your query. You can also consider a subquery likeSELECT d.x FROM d WHERE d.id=b.id, that might help. But I don't see how this can work for both=and!=. - Marcin Zukowski