sergecom
New Contributor III

Thanks for feedback @MarcoI've also tested with an older All-purpose Runtime 12.2 LTS and it works.
But its alarming that the latest runtime does not work as expected.

I will post SQL code so it will be easier for other to test. Both these queries give wrong results:

%sql
WITH a AS (
    SELECT 'aaa' as produktkod
    UNION ALL
    SELECT 'bbb'  as produktkod
),
b AS (
    SELECT 'aaa' as produktkod
    UNION ALL
    SELECT 'ccc'  as produktkod
)
SELECT a.*
FROM a
WHERE exists (
  select 1 from b where a.produktkod = b.produktkod
);

%sql
WITH a AS (
SELECT 'aaa' as produktkod
UNION ALL
SELECT 'bbb' as produktkod
),
b AS (
SELECT 'aaa' as produktkod
UNION ALL
SELECT 'ccc' as produktkod
)
SELECT a.*,
(SELECT COUNT(1)
FROM b
WHERE b.produktkod = a.produktkod) as match_count
FROM a;